Skip to main content Link Menu Expand (external link) Document Search Copy Copied

fp-ts logo

Typed functional programming in TypeScript
TypeScript 中的类型化函数式编程

fp-ts provides developers with popular patterns and reliable abstractions from typed functional languages in TypeScript.
fp-ts 为开发人员提供了 TypeScript 中类型化函数语言的流行模式和可靠抽象。

Disclaimer. Teaching functional programming is out of scope of this project, so the documentation assumes you already know what FP is.
免责声明。教授函数式编程超出了本项目的范围,因此文档假设您已经知道 FP 是什么。

Core Concepts   核心概念

The goal of fp-ts is to empower developers to write pure FP apps and libraries built atop higher order abstractions. It includes the most popular data types, type classes, and abstractions from languages like Haskell, PureScript, and Scala.
fp-ts 的目标是使开发人员能够编写构建在高阶抽象之上的纯 FP 应用程序和库。它包括最流行的数据类型、类型类以及 Haskell、PureScript 和 Scala 等语言的抽象。

Functions   功能

Functional programming is all about pure functions and how to compose them into bigger structures. fp-ts provides a few general functions to support you with composition, constant functions, and more.
函数式编程都是关于纯函数以及如何将它们组合成更大的结构。 fp-ts 提供了一些通用函数来支持您的组合、常量函数等。

Data Types   数据类型

Data types are the practical part of fp-ts: you can instantiate them with your data to gain properties and functionality that are useful for solving a specific need. Because data types all share common interfaces (through type classes), once you learn how to use one data type, you can apply the same concepts to the others.
数据类型是 fp-ts 的实用部分:您可以使用数据实例化它们,以获得有助于解决特定需求的属性和功能。由于数据类型都共享公共接口(通过类型类),因此一旦您学习了如何使用一种数据类型,您就可以将相同的概念应用于其他数据类型。

Many functions in fp-ts use ad hoc polymorphism, meaning that they have a single implementation that can deal with arguments of different types. To make this work, it is often necessary to provide a data type instance that provides functionality that is specific to the data type.
fp-ts 中的许多函数使用临时多态性,这意味着它们有一个可以处理不同类型参数的实现。为了实现这一点,通常需要提供一个数据类型实例来提供特定于该数据类型的功能。

Note. Data types are not stack safe and there is no trampolining implementation. But for traversing and sequencing lists there is a stack safe and optimized version in each data types.
笔记。数据类型不是堆栈安全的,并且没有蹦床实现。但对于遍历和排序列表,每种数据类型都有一个堆栈安全和优化的版本。

Type Classes   类型类别

Type classes provide the theoretical underpinnings of fp-ts: they describe what you can do with your data. To guarantee that they can be safely composed, they are built on laws rooted in abstract algebra and category theory.
类型类提供了 fp-ts 的理论基础:它们描述了您可以对数据执行哪些操作。为了保证它们可以安全地组合,它们建立在植根于抽象代数和范畴论的定律之上。

Higher Kinded Types
高等种类

A distinctive feature of fp-ts with respect to other functional libraries is its implementation of Higher Kinded Types, which TypeScript doesn’t support natively. The idea for emulating higher kinded types in TypeScript is based on Lightweight higher-kinded polymorphism.
相对于其他函数库, fp-ts 的一个显着特征是它实现了更高种类的类型,而 TypeScript 本身并不支持这种类型。在 TypeScript 中模拟更高种类类型的想法基于轻量级更高种类多态性。

Learning Resources  学习资源

Getting started with fp-ts series
FP-TS系列入门

Functional design series
功能设计系​​列

Advanced code examples
高级代码示例

Community documentation
社区文档

Community Blog Posts
社区博客文章

Ecosystem   生态系统

Tooling  工装

  • create-fp-ts-lib - Bootstrap libraries that follow common fp-ts coding, documentation and testing patterns
    create-fp-ts-lib - 遵循常见 fp-ts 编码、文档和测试模式的引导库
  • docs-ts - Documentation generator used by fp-ts and many fp-ts libraries
    docs-ts - fp-ts 和许多 fp-ts 库使用的文档生成器

Libraries   图书馆

  • fp-ts-contrib - A community driven utility package for fp-ts
    fp-ts-contrib - 社区驱动的 fp-ts 实用程序包
  • fp-ts-codegen - TypeScript code generation from a haskell-like syntax for ADT
    fp-ts-codegen - 从类似于 Haskell 的 ADT 语法生成 TypeScript 代码
  • io-ts - TypeScript compatible runtime type system for IO validation
    io-ts - 用于 IO 验证的 TypeScript 兼容运行时类型系统
  • monocle-ts - Functional optics: a (partial) porting of scala monocle to TypeScript
    monocle-ts - 功能光学:将 scala monocle(部分)移植到 TypeScript
  • spectacles-ts - A simple facade built on top of monocle-ts (autocompletes possible combinators)
    spectacles-ts - 建立在 monocle-ts 之上的简单外观(自动完成可能的组合器)
  • newtype-ts - Implementation of newtypes in TypeScript
    newtype-ts - TypeScript 中新类型的实现
  • logging-ts - Composable loggers for TypeScript
    logging-ts - TypeScript 的可组合记录器
  • logger-fp-ts - Logger built on top of logging-ts
    logger-fp-ts - 构建在logging-ts之上的记录器
  • fp-ts-routing - A type-safe bidirectional routing library for TypeScript
    fp-ts-routing - TypeScript 的类型安全双向路由库
  • parser-ts - String parser combinators for TypeScript
    parser-ts - TypeScript 的字符串解析器组合器
  • remote-data-ts - RemoteData type (check this article)
    Remote-data-ts - RemoteData 类型(查看本文)
  • retry-ts - Retry combinators for monadic actions that may fail
    retry-ts - 重试可能失败的单子操作的组合器
  • fp-ts-local-storage - fp-ts bindings for LocalStorage
    fp-ts-local-storage - LocalStorage 的 fp-ts 绑定
  • circuit-breaker-monad - Circuit Breaker pattern as a monad
    Circuit-breaker-monad - 作为 monad 的断路器模式
  • waveguide - Bifunctor effect type and concurrent data structures.
    波导 - 双函子效应类型和并发数据结构。
  • kleisli-ts - Kleisli arrows for bifunctor MonadThrow (IOEither, TaskEither)
    kleisli-ts - 双函子 MonadThrow 的 Kleisli 箭头(IOEither,TaskEither)
  • @nll/datum - Datum and DatumEither types, another take on RemoteData and flow
    @nll/datum - Datum 和 DatumEither 类型,RemoteData 和 flow 的另一种形式
  • fetcher-ts - Type-safe REST HTTP client with io-ts response validation
    fetcher-ts - 具有 io-ts 响应验证的类型安全 REST HTTP 客户端
  • alga-ts – Algebraic encoding for graphs, which makes invalid graphs unrepresentable
    alga-ts – 图的代数编码,这使得无效图无法表示
  • morphic-ts - Code first Domain modeling with extensive pattern supports (matchers, predicates, lenses) with useful, extensible, customisable derivations (Show, Eq, io-ts, fast-check, jsonSchema, ..).
    morphic-ts - 具有广泛模式支持(匹配器、谓词、镜头)的代码优先域建模,具有有用的、可扩展的、可定制的派生(Show、Eq、io-ts、快速检查、jsonSchema、..)。
  • graphics-ts - A porting of purescript-{canvas, drawing} featuring fp-ts
    Graphics-ts - 以 fp-ts 为特色的 purescript-{canvas, Drawing} 的移植
  • expressive-ts - Comonadic builders for writing complex regular expressions
    expressive-ts - 用于编写复杂正则表达式的 Comonadic 构建器
  • fp-fetch - Functional style, non-throwing utils for data fetching
    fp-fetch - 函数式风格,用于数据获取的非抛出实用程序
  • fp-ts-std - The missing pseudo-standard library for fp-ts.
    fp-ts-std - fp-ts 缺少的伪标准库。
  • fp-ts-lcg - A seeded pseudorandom number generator
    fp-ts-lcg - 种子伪随机数生成器
  • fp-ts-graph - Immutable, functional graph data structure
    fp-ts-graph - 不可变的函数图数据结构
  • fp-ts-bigint - Opt-in BigInt functions
    fp-ts-bigint - 选择加入 BigInt 函数
  • fp-ts-generators - Seeded pseudorandom generators for structured data
    fp-ts-generators - 用于结构化数据的种子伪随机生成器
  • fp-ts-sized-vectors - Fixed size generic vector type carrying its length at the typelevel
    fp-ts-sized-vectors - 固定大小的通用向量类型在类型级别承载其长度
  • fp-ts-number-instances - Not fully law abiding instances for the number type
    fp-ts-number-instances - 数字类型不完全符合法律的实例
  • fp-ts-react-stable-hooks - Reduce unnecessary rerenders when using fp-ts data types with React hooks
    fp-ts-react-stable-hooks - 在 React hooks 中使用 fp-ts 数据类型时减少不必要的重新渲染

Bindings   绑定

Plugins   插件

  • fastify-funky - plugin that adds support for returning fp-ts Either and Task entities as handler execution results for fastify web framework
    fastify-funky - 插件添加了对返回 fp-ts Either 和 Task 实体作为 fastify Web 框架的处理程序执行结果的支持

Guides   指南


Table of contents 目录

Code Conventions  代码约定

Table of contents 目录

Module structure  模块结构

In general a module containing the definition of a data structure has the following structure
一般来说,包含数据结构定义的模块具有以下结构

  • URI definition and module augmentation
    URI 定义和模块扩充
  • data structure definition
    数据结构定义
  • companion functions 伴随函数
  • instance functions (private)
    实例函数(私有)
  • type class instance definitions (either constants or functions)
    类型类实例定义(常量或函数)

FAQ  常问问题

What a C suffix means, e.g. Functor2C vs Functor2
C 后缀的含义是什么,例如 Functor2CFunctor2

The naming convention is:
命名约定是:

  • the number means the kind
    数字代表种类
  • C means Constrained  C 表示受约束
Kind 种类 Type class 类型类别 Type defunctionalization
类型去功能化
Note 笔记
all 全部 Functor<F> HKT<F, A>  
* -> * Functor1<F> Kind<F, A>  
* -> * -> * Functor2<F> Kind2<F, E, A>  
* -> * -> * Functor2C<F, E> Kind2<F, E, A> A variant of Functor2 where E is fixed
Functor2 的变体,其中 E 是固定的
* -> * -> * -> * Functor3<F> Kind3<F, R, E, A>  
* -> * -> * -> * Functor3C<F, R, E> Kind3<F, R, E, A> A variant of Functor3 where both R and E are fixed
Functor3 的变体,其中 RE 都是固定的

Example Functor 示例 Functor

The base definition 基本定义

export interface Functor<F> {
  readonly URI: F
  readonly map: <A, B>(fa: HKT<F, A>, f: (a: A) => B) => HKT<F, B>
}

The definition for type constructors of kind * -> * -> * (e.g. Either)
* -> * -> * 类型构造函数的定义(例如 Either

export interface Functor2<F extends URIS2> {
  readonly URI: F
  //             v-- here E is free
  readonly map: <E, A, B>(fa: Kind2<F, E, A>, f: (a: A) => B) => Kind2<F, E, B>
}

The definition for type constructors that start with kind * -> * -> * but need to be constrained in order to admit an instance (e.g. Validation).
* -> * -> * 开头但需要受到约束才能接纳实例的类型构造函数的定义(例如 Validation )。

//                           this fixes E --v
export interface Functor2C<F extends URIS2, E> {
  readonly URI: F
  readonly _E: E
  //                                v-- here E is fixed ---------------v
  readonly map: <A, B>(fa: Kind2<F, E, A>, f: (a: A) => B) => Kind2<F, E, B>
}

For example, Validation admits a Functor instance only if you provide a Semigroup instance for the failure part
例如,仅当您为失败部分提供 Semigroup 实例时, Validation 才会接纳 Functor 实例

//   this fixes E --v                                            v-- here E is fixed
const getFunctor = <E>(S: Semigroup<E>): Functor2C<"Validation", E> = { ... }

What an E suffix means, e.g. matchE
E 后缀的含义是什么,例如 matchE

E means Effect. An example of its use is in the matchE destructor on monad transformers like TaskOption or ReaderTaskEither.
E 表示效果。它的使用示例是 TaskOptionReaderTaskEither 等 monad 转换器上的 matchE 析构函数。

Example 例子

Both of these destructions result in a Task<number>, but in the case of matchE an effect (in this case in the form of a Task) is returned on match.
这两种破坏都会产生 Task<number> ,但在 matchE 的情况下,会在匹配时返回效果(在本例中以 Task 的形式)。

import * as T from 'fp-ts/Task'
import * as TO from 'fp-ts/TaskOption'
import { pipe } from 'fp-ts/function'

const value = TO.of('hello')

// T.Task<number>
pipe(
  value,
  TO.match(
    () => 0,
    (str) => str.length
  )
)

// T.Task<number>
pipe(
  value,
  TO.matchE(
    () => T.of(0),
    (str) => T.of(str.length)
  )
)

What a K suffix means, e.g. fromEitherK or chainEitherK
K 后缀的含义是什么,例如 fromEitherKchainEitherK

K means Kleisli. A Kleisli arrow is a function with the following signature
K 表示克莱斯利。 Kleisli 箭头是具有以下签名的函数

(a: A) => F<B>

where F is a type constructor.
其中 F 是类型构造函数。

Example 例子

Let’s say we have the following parser
假设我们有以下解析器

import * as E from 'fp-ts/Either'

function parse(s: string): E.Either<Error, number> {
  const n = parseFloat(s)
  return isNaN(n) ? E.left(new Error(`cannot decode ${JSON.stringify(s)} to number`)) : E.right(n)
}

and a value of type IOEither<Error, string>
和一个@0类型的值#

import * as IE from 'fp-ts/IOEither'

const input: IE.IOEither<Error, string> = IE.right('foo')

how can we parse input?
我们如何解析 input

We could lift the Kleisli arrow parse, i.e. transform a function
我们可以举起 Kleisli 箭头 parse ,即变换一个函数

(s: string) => E.Either<Error, number>

into a function 变成一个函数

(s: string) => IE.IOEither<Error, number>

That’s what fromEitherK is all about
这就是 fromEitherK 的意义所在

import { pipe } from 'fp-ts/function'

pipe(input, IE.chain(IE.fromEitherK(parse)))() // left(new Error('cannot decode "foo" to number'))

// or with less boilerplate
pipe(input, IE.chainEitherK(parse))() // left(new Error('cannot decode "foo" to number'))

What a T suffix means, e.g. sequenceT
T 后缀的含义是什么,例如 sequenceT

in sequenceT means Tuple, I borrowed the name from the corresponding Haskell function
sequenceT 中的意思是Tuple,这个名字我借用了对应的Haskell函数

However usually it means Transformer like in “monad transformers” (e.g. OptionT, EitherT, ReaderT, StateT)
然而,它通常意味着 Transformer,就像“monad 转换器”中的那样(例如 OptionTEitherTReaderTStateT

What a W suffix means, e.g. chainW or chainEitherKW
W 后缀的含义是什么,例如 chainWchainEitherKW

W means Widen. Functions that end with W are able to aggregate errors into a union (for Either based data types) or environments into an intersection (for Reader based data types).
W 表示加宽。以 W 结尾的函数能够将错误聚合到联合(对于基于 Either 的数据类型)或将环境聚合到交集(对于基于 Reader 的数据类型)。

Example 例子

import * as E from 'fp-ts/Either'
import * as TE from 'fp-ts/TaskEither'
import { pipe } from 'fp-ts/pipeable'

declare function parseString(s: string): E.Either<string, number>
declare function fetchUser(id: number): TE.TaskEither<Error, User>

// this raises an error because: Type 'string' is not assignable to type 'Error'
const program_ = (s: string) => pipe(s, TE.fromEitherK(parseString), TE.chain(fetchUser))

// const program: (s: string) => TE.TaskEither<string | Error, User>
const program = (s: string) => pipe(s, TE.fromEitherK(parseString), TE.chainW(fetchUser))

How to write type class instances for your data type
如何为您的数据类型编写类型类实例

Let’s start from a simple data structure: Identity
让我们从一个简单的数据结构开始: Identity

// Identity.ts

export type Identity<A> = A

Functor instance  函子实例

Let’s see how to add an instance of the Functor type class for Identity
让我们看看如何为 Identity 添加 Functor 类型类的实例

// Identity.ts

import { Functor1 } from 'fp-ts/Functor'

export const URI = 'Identity'

export type URI = typeof URI

declare module 'fp-ts/HKT' {
  interface URItoKind<A> {
    readonly Identity: Identity<A>
  }
}

export type Identity<A> = A

// Functor instance
export const Functor: Functor1<URI> = {
  URI,
  map: (ma, f) => f(ma)
}

Here’s the definition of Functor1
这是 Functor1 的定义

// fp-ts/Functor.ts

export interface Functor1<F extends URIS> {
  readonly URI: F
  readonly map: <A, B>(fa: Kind<F, A>, f: (a: A) => B) => Kind<F, B>
}

So what’s URItoKind, URIS and Kind?
那么 URItoKindURISKind 是什么?

URItoKind is type-level map, it maps a URI to a concrete data type, and is populated using the module augmentation feature
URItoKind 是类型级映射,它将 URI 映射到具体数据类型,并使用模块增强功能进行填充

// fp-ts/HKT.ts

export interface URItoKind<A> {}
// Identity.ts

declare module 'fp-ts/HKT' {
  interface URItoKind<A> {
    readonly Identity: Identity<A> // maps the key "Identity" to the type `Identity`
  }
}

URIS is just keyof URItoKind<any> and is used as a constraint in the Functor1 interface
URIS 只是 keyof URItoKind<any> ,并在 Functor1 接口中用作约束

Kind<F, A> is using URItoKind internally so is able to project an abstract data type to a concrete data type. So if URI = 'Identity', then Kind<URI, number> is Identity<number>.
Kind<F, A> 在内部使用 URItoKind ,因此能够将抽象数据类型投影为具体数据类型。所以如果 URI = 'Identity' ,那么 Kind<URI, number> 就是 Identity<number>

What about type constructors of kind * -> * -> *?
* -> * -> * 类型的类型构造函数怎么样?

There’s another triple for that: URItoKind2, URIS2 and Kind2
还有另一个三元组: URItoKind2URIS2Kind2

Example: Either 示例: Either

// Either.ts

import { Functor2 } from 'fp-ts/Functor'

export const URI = 'Either'

export type URI = typeof URI

declare module 'fp-ts/HKT' {
  interface URItoKind2<E, A> {
    readonly Either: Either<E, A>
  }
}

export interface Left<E> {
  readonly _tag: 'Left'
  readonly left: E
}

export interface Right<A> {
  readonly _tag: 'Right'
  readonly right: A
}

export type Either<E, A> = Left<E> | Right<A>

export const right = <A, E = never>(a: A): Either<E, A> => ({ _tag: 'Right', right: a })

// Functor instance
export const Functor: Functor2<URI> = {
  URI,
  map: (ma, f) => (ma._tag === 'Left' ? ma : right(f(ma.right)))
}

And here’s the definition of Functor2
这是 Functor2 的定义

// fp-ts/Functor.ts

export interface Functor2<F extends URIS2> {
  readonly URI: F
  readonly map: <E, A, B>(fa: Kind2<F, E, A>, f: (a: A) => B) => Kind2<F, E, B>
}

How to type functions which abstracts over type classes
如何输入抽象类型类的函数

Let’s see how to type lift
让我们看看如何输入 lift

import { HKT } from 'fp-ts/HKT'

export function lift<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => (fa: HKT<F, A>) => HKT<F, B> {
  return (f) => (fa) => F.map(fa, f)
}

Here’s the definition of HKT
这是 HKT 的定义

// fp-ts/HKT.ts

export interface HKT<URI, A> {
  readonly _URI: URI
  readonly _A: A
}

The HKT type represents a type constructor of kind * -> *.
HKT 类型表示 * -> * 类型的类型构造函数。

There are other HKT<n> types defined in the fp-ts/HKT.ts, one for each kind (up to four):
fp-ts/HKT.ts 中定义了其他 HKT<n> 类型,每种类型一个(最多四种):

  • HKT2 for type constructors of kind * -> * -> *
    HKT2 用于 * -> * -> * 类型的类型构造函数
  • HKT3 for type constructors of kind * -> * -> * -> *
    HKT3 用于 * -> * -> * -> * 类型的类型构造函数
  • HKT4 for type constructors of kind * -> * -> * -> * -> *
    HKT4 用于 * -> * -> * -> * -> * 类型的类型构造函数

There’s a problem though, this doesn’t type check
但有一个问题,这不会进行类型检查

const double = (n: number): number => n * 2

//                             v-- the Functor instance of Identity
const doubleIdentity = lift(identity)(double)

With the following error
出现以下错误

Argument of type 'Functor1<"Identity">' is not assignable to parameter of type 'Functor<"Identity">'

We need to add some overloading, one for each kind we want to support
我们需要添加一些重载,每种我们想要支持的类型一个

export function lift<F extends URIS2>(
  F: Functor2<F>
): <A, B>(f: (a: A) => B) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>
export function lift<F extends URIS>(F: Functor1<F>): <A, B>(f: (a: A) => B) => (fa: Kind<F, A>) => Kind<F, B>
export function lift<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => (fa: HKT<F, A>) => HKT<F, B>
export function lift<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => (fa: HKT<F, A>) => HKT<F, B> {
  return (f) => (fa) => F.map(fa, f)
}

Now we can lift double to both Identity and Either
现在我们可以将 double 提升为 IdentityEither

//                             v-- the Functor instance of Identity
const doubleIdentity = lift(identity)(double)

//                           v-- the Functor instance of Either
const doubleEither = lift(either)(double)
  • doubleIdentity has type (fa: Identity<number>) => Identity<number>
    doubleIdentity 的类型为 (fa: Identity<number>) => Identity<number>
  • doubleEither has type <E>(fa: Either<E, number>) => Either<E, number>
    doubleEither 的类型为 <E>(fa: Either<E, number>) => Either<E, number>

Migrate from PureScript/Haskell
从 PureScript/Haskell 迁移

This guide shows you how to use fp-ts concepts if you have prior experience with PureScript or Haskell.
如果您之前有使用 PureScript 或 Haskell 的经验,本指南将向您展示如何使用 fp-ts 概念。


Do notation   做记号

PureScript 纯脚本

do
  print "foo"
  print "bar"
  x <- readLine
  print x

TypeScript  打字稿

import { pipe } from 'fp-ts/function'
import * as T from 'fp-ts/Task'

declare const print: (s: string) => T.Task<void>
declare const readLine: T.Task<string>

pipe(
  T.Do,
  T.tap(() => print('foo')),
  T.tap(() => print('bar')),
  T.bind('x', () => readLine),
  T.flatMap(({ x }) => print(x))
)

Data   数据

PureScript 纯脚本

--   ↓-- type
data Foo = Bar String | Baz Boolean
--         ↑------------↑-- constructors

TypeScript  打字稿

interface Bar {
  readonly _tag: 'Bar'
  readonly value: string
}

interface Baz {
  readonly _tag: 'Baz'
  readonly value: boolean
}

// type
type Foo = Bar | Baz

// constructors
const Bar = (value: string): Foo => ({ _tag: 'Bar', value })

const Baz = (value: boolean): Foo => ({ _tag: 'Baz', value })

Polymorphic data   多态性数据

PureScript 纯脚本

data Option a = None | Some a

TypeScript  打字稿

export const URI = 'Option'

export type URI = typeof URI

declare module 'fp-ts/HKT' {
  interface URItoKind<A> {
    readonly [URI]: Option<A>
  }
}

export interface None {
  readonly _tag: 'None'
}

export interface Some<A> {
  readonly _tag: 'Some'
  readonly value: A
}

export type Option<A> = None | Some<A>

export const none: Option<never> = { _tag: 'None' }

export const some = <A>(a: A): Option<A> => ({ _tag: 'Some', value: a })

Pattern matching  模式匹配

PureScript 纯脚本

maybe :: forall a b. b -> (a -> b) -> Option a -> b
maybe b _ None = b
maybe _ f (Some a) = f a

TypeScript  打字稿

// here TypeScript also provides exhaustiveness check
const maybe =
  <A, B>(onNone: () => B, onSome: (a: A) => B) =>
  (fa: Option<A>): B => {
    switch (fa._tag) {
      case 'None':
        return onNone()
      case 'Some':
        return onSome(fa.value)
    }
  }

Type classes   类型类别

PureScript 纯脚本

class Functor f where
  map :: forall a b. (a -> b) -> f a -> f b

TypeScript  打字稿

export interface Functor<F> {
  readonly URI: F
  readonly map: <A, B>(fa: HKT<F, A>, f: (a: A) => B) => HKT<F, B>
}

export interface Functor1<F extends URIS> {
  readonly URI: F
  readonly map: <A, B>(fa: Kind<F, A>, f: (a: A) => B) => Kind<F, B>
}

export interface Functor2<F extends URIS2> {
  readonly URI: F
  readonly map: <E, A, B>(fa: Kind2<F, E, A>, f: (a: A) => B) => Kind2<F, E, B>
}

// etc...

Instances   实例

PureScript 纯脚本

instance functorOption :: Functor Option where
  map fn (Some x) = Some (fn x)
  map _  _        = None

TypeScript  打字稿

import { Functor1 } from 'fp-ts/Functor'
import { pipe } from 'fp-ts/function'

const functorOption: Functor1<URI> = {
  URI,
  map: (fa, f) =>
    pipe(
      fa,
      maybe(
        () => none,
        (a) => some(f(a))
      )
    )
}

Type constraints   类型限制

PureScript 纯脚本

instance semigroupOption :: Semigroup a => Semigroup (Option a) where
  append None y = y
  append x None = x
  append (Some x) (Some y) = Some (x <> y)

instance monoidOption :: Semigroup a => Monoid (Option a) where
  mempty = None

TypeScript  打字稿

import { Semigroup } from 'fp-ts/Semigroup'
import { Monoid } from 'fp-ts/Monoid'

//                    ↓ the constraint is implemented as an additional parameter
function getMonoid<A>(S: Semigroup<A>): Monoid<Option<A>> {
  return {
    concat: (x, y) => {
      if (x._tag === 'Some' && y._tag === 'Some') {
        return some(S.concat(x.value, y.value))
      } else if (x._tag === 'Some') {
        return y
      } else {
        return x
      }
    },
    empty: none
  }
}

Where’s my f <$> fa <*> fb?
我的 f <$> fa <*> fb 在哪里?

A few options: 几个选项:

import * as T from 'fp-ts/Task'
import { pipe } from 'fp-ts/function'

declare const fa: T.Task<number>
declare const fb: T.Task<string>
declare const f: (a: number) => (b: string) => boolean

const result1 = pipe(fa, T.map(f), T.ap(fb))

// ..or..
const result2 = pipe(T.of(f), T.ap(fa), T.ap(fb))

Do Notation   做记号

Both Haskell and PureScript languages provide syntactic sugar for working with monads in the form of do notation.
Haskell 和 PureScript 语言都以 do 表示法的形式提供了处理 monad 的语法糖。

fp-ts provides it’s own implementation of do notation which can help to simplify effectful code.
fp-ts 提供了它自己的 do 表示法的实现,可以帮助简化有效的代码。

Let’s take a look at an example of how do notation can help to simplify our code. Here we have a bit of code which reads two values from the command line, prints them and stores them in an object with x and y properties.
让我们看一个示例,了解 do 表示法如何帮助简化我们的代码。这里我们有一些代码,它从命令行读取两个值,打印它们并将它们存储在具有 xy 属性的对象中。

import { pipe } from 'fp-ts/function'
import * as T from 'fp-ts/Task'

declare const print: (s: string) => T.Task<void>
declare const readLine: T.Task<string>

const main: T.Task<{ x: string; y: string }> = pipe(
  readLine,
  T.map((x) => ({ x })),
  T.flatMap(({ x }) =>
    pipe(
      readLine,
      T.map((y) => ({ x, y }))
    )
  ),
  T.tap(({ x }) => print(x)),
  T.tap(({ y }) => print(y))
)

Notice how we need a nested pipe to allow the combination of x and y values into a single object.
请注意,我们如何需要嵌套的 pipe 来允许将 xy 值组合到单个对象中。

Here’s how we can write main with do notation (we’ll call it mainDo):
下面是我们如何使用 do 表示法编写 main (我们将其称为 mainDo ):

const mainDo: T.Task<{ x: string; y: string }> = pipe(
  T.Do,
  T.bind('x', () => readLine),
  T.bind('y', () => readLine),
  T.tap(({ x }) => print(x)),
  T.tap(({ y }) => print(y))
)

This will look very familiar to those who have prior experience with Purescript or Haskell where we could write something like:
对于那些有 Purescript 或 Haskell 经验的人来说,这看起来非常熟悉,我们可以编写如下内容:

main :: IO (String, String)
main = do
  x <- readLn
  y <- readLn
  print x
  print y
  return (x, y)

Note that due to the lack of type-classes in Typescript, when working with fp-ts we need to import everything from the appropriate module. In the previous example, we use specific Do, bind, map and chainFirst functions imported from the Task module as we were working with the Task type.
请注意,由于 Typescript 中缺少类型类,因此在使用 fp-ts 时,我们需要从适当的模块导入所有内容。在前面的示例中,我们使用从 Task 模块导入的特定 DobindmapchainFirst 函数,就像我们使用 Task 类型一样。

If we were to write the same code using the IO monad, we would need to import everything from the IO module like so:
如果我们要使用 IO monad 编写相同的代码,则需要从 IO 模块导入所有内容,如下所示:

import { pipe } from 'fp-ts/function'
import * as IO from 'fp-ts/IO'

declare const print: (s: string) => IO.IO<void>
declare const readLine: IO.IO<string>

const mainDo: IO.IO<{ x: string; y: string }> = pipe(
  IO.Do,
  IO.bind('x', () => readLine),
  IO.bind('y', () => readLine),
  IO.tap(({ x }) => print(x)),
  IO.tap(({ y }) => print(y))
)

Examples   例子

Using bindTo: 使用 bindTo

import { pipe } from 'fp-ts/function'
import * as T from 'fp-ts/Task'

declare const print: (s: string) => T.Task<void>
declare const readLine: T.Task<string>

pipe(
  readLine,
  T.bindTo('x'),
  T.bind('y', () => readLine),
  T.tap(({ x }) => print(x)),
  T.tap(({ y }) => print(y))
)

Performing actions in parallel with apS:
apS 并行执行操作:

import { pipe } from 'fp-ts/function'
import * as T from 'fp-ts/Task'

declare const encryptValue: (val: string) => T.Task<string>

pipe(
  T.Do,
  T.apS('x', encryptValue('hello')),
  T.apS('y', encryptValue('world')),
  T.map(({ x, y }) => {
    /* ... */
  })
)

FAQ   常问问题

What does IO.Do do exactly?
IO.Do 到底做了什么?

IO.Do is just an alias for IO.of({}) where {} is an empty record.
IO.Do 只是 IO.of({}) 的别名,其中 {} 是空记录。

You build up a record using bind which accepts a key and a function that accepts the current state of the record and returns an effect of some value to store under the key.
您使用 bind 构建一条记录,它接受一个键和一个函数,该函数接受记录的当前状态并返回某个值的效果以存储在该键下。

The record becomes kind of like a scope to put intermediate values in when you are chaining effects.
当您链接效果时,记录变得有点像放置中间值的范围。

Upgrade to version 2.x
升级到版本2.x

fp-ts@2.x brings with it some major improvements, but also breaking changes and the removal of deprecated APIs. This document will help you understand what changed and how you can upgrade your existing codebase.
fp-ts@2.x 带来了一些重大改进,但也带来了重大更改和删除了已弃用的 API。本文档将帮助您了解更改的内容以及如何升级现有代码库。


The major changes in fp-ts@2.x are:
fp-ts@2.x 的主要变化是:

  • Requires TypeScript 3.5+
    需要 TypeScript 3.5+
  • fp-ts@1.19.x has been released with backported 2.x features for a gradual upgrade path
    fp-ts@1.19.x 已发布,并带有向后移植的 2.x 功能,用于逐步升级路径
  • Data types are no longer implemented as classes, resulting in a new API using pipe
    数据类型不再作为类实现,从而产生了使用 pipe 的新 API
  • The run() method on IO, Task, etc. has been replaced with a thunk
    IOTask 等上的 run() 方法已被替换为thunk
  • Functions accepting fallback values are now always lazy (e.g. getOrElseL is now just getOrElse)
    接受后备值的函数现在总是惰性的(例如 getOrElseL 现在只是 getOrElse
  • Deprecations  弃用
    • HKT: Replaced Type<n> with Kind<n>
      HKT :将 Type<n> 替换为 Kind<n>
    • Replaced Setoid with Eq Setoid 替换为 Eq
    • Several modules were removed, e.g. Exception, Free, StrMap, Trace, Validation, …
      删除了几个模块,例如 ExceptionFreeStrMapTraceValidation 、……
    • Read the full changelog for all the changes
      阅读完整的变更日志以了解所有更改

Upgrading from version 1.x
从版本 1.x 升级

You can gradually upgrade your existing codebase using the fp-ts@1.19.x release; the new fp-ts@2.x APIs have been backported to this release.
您可以使用 fp-ts@1.19.x 版本逐步升级现有的代码库;新的 fp-ts@2.x API 已向后移植到此版本。

  1. Upgrade TypeScript to version 3.5+
    将 TypeScript 升级到版本 3.5+
  2. Install fp-ts@1.19.x, which contains the new fp-ts@2.x APIs
    安装 fp-ts@1.19.x ,其中包含新的 fp-ts@2.x API
  3. Optional: activate the @obsolete rule for tslint to get guidance on what to change
    可选:激活 tslint@obsolete 规则以获取有关更改内容的指导
  4. Familiarise yourself with the new API
    熟悉新的 API
  5. Gradually replace the existing code with the new API
    逐步用新的 API 替换现有代码
  6. Upgrade to fp-ts@2.x and make sure to also upgrade all dependencies that rely on fp-ts
    升级到 fp-ts@2.x 并确保也升级依赖于 fp-ts 的所有依赖项

tslint rule   tslint 规则

In order to make easier to spot all the occurrences of chainable APIs without depending on @deprecated, which would force you to migrate in one shot, a custom tslint rule is provided (@obsolete).
为了更容易地发现所有可链接 API 的出现,而不依赖于 @deprecated (这会迫使您一次性迁移),提供了一个自定义 tslint 规则 ( @obsolete )。

Add the following lines to your tslint.json to turn the @obsolete rule on:
将以下行添加到 tslint.json 以打开 @obsolete 规则:

{
+  "rulesDirectory": ["./node_modules/fp-ts/rules"],
   "rules": {
+    "obsolete": true
   }
}

This rule is available in the 1.19.x branch.
此规则在 1.19.x 分支中可用。

Dependencies   依赖关系

Don’t forget to update your dependencies: libraries that use fp-ts like io-ts or monocle-ts have to be upgraded to their fp-ts@2.x compatible versions.
不要忘记更新您的依赖项:使用 fp-ts (如 io-ts 或 monocle-ts)的库必须升级到其 fp-ts@2.x 兼容版本。

The new API
新的API

In fp-ts@2.x data types are no longer implemented with classes; the biggest change resulting from this is that the chainable API has been removed. As an alternative, a pipe function is provided, along with suitable data-last top level functions (one for each deprecated method). This is best shown with an example:
fp-ts@2.x 中,数据类型不再用类来实现;由此带来的最大变化是可链接 API 已被删除。作为替代方案,提供了 pipe 函数以及合适的 data-last 顶级函数(每个已弃用的方法都有一个)。最好用一个例子来说明这一点:

v1 (deprecated) V1(已弃用)

import * as O from 'fp-ts/Option'

O.some(1)
  .map((n) => n * 2)
  .chain((n) => (n === 0 ? O.none : O.some(1 / n)))
  .filter((n) => n > 1)
  .foldL(
    () => 'ko',
    () => 'ok'
  )

v2 (new) V2(新)

import * as O from 'fp-ts/Option'
import { pipe } from 'fp-ts/pipeable'

pipe(
  O.some(1),
  O.map((n) => n * 2),
  O.chain((n) => (n === 0 ? O.none : O.some(1 / n))),
  O.filter((n) => n > 1),
  O.fold(
    () => 'ko',
    () => 'ok'
  )
)

We recommend to use pipe even if you work with just one function, as it allows TypeScript to infer the types automatically. It’s also easier to migrate existing code, because the argument order remains the same.
即使您只使用一个函数,我们也建议使用 pipe ,因为它允许 TypeScript 自动推断类型。迁移现有代码也更容易,因为参数顺序保持不变。

import * as O from 'fp-ts/Option'
import { pipe } from 'fp-ts/function'

pipe(
  O.some(1),
  O.fold(
    () => 'ko',
    (n) => `ok: ${n}`
  )
)

If you are interested, read about the benefits of the new API in the technical discussion leading to fp-ts@2.x.
如果您有兴趣,请在 fp-ts@2.x 的技术讨论中了解新 API 的优势。

Replacement of the run() method
替换 run() 方法

The run() method on IO, Task, etc. has been replaced with a thunk:
IOTask 等上的 run() 方法已替换为 thunk:

v1 (deprecated) V1(已弃用)

import { Task } from 'fp-ts/Task'

const deepThought = new Task<number>(() => Promise.resolve(42))

deepThought.run().then((n) => {
  console.log(`The answer is ${n}.`)
})

v2 (new) V2(新)

import { Task } from 'fp-ts/Task'

const deepThought: Task<number> = () => Promise.resolve(42)

deepThought().then((n) => {
  console.log(`The answer is ${n}.`)
})

Functions accepting fallback values are now always lazy
接受后备值的函数现在总是惰性的

In many places fp-ts@1.x provided two versions of methods:
在很多地方 fp-ts@1.x 提供了两个版本的方法:

v1 (deprecated) V1(已弃用)

import * as O from 'fp-ts/Option'

O.some(1).getOrElse(0) // Direct
O.some(1).getOrElseL(() => 0) // Lazy, i.e. only run if needed

v2 (new) V2(新)

In fp-ts@2.x the API has been simplified, only the lazy variants have been kept with the L suffix removed.
fp-ts@2.x 中,API 得到了简化,仅保留了惰性变体,并删除了 L 后缀。

import * as O from 'fp-ts/Option'
import { pipe } from 'fp-ts/function'

pipe(
  O.some(1),
  O.getOrElse(() => 0)
)

Removed modules   删除的模块

  • Exception
  • Free
  • FreeGroup
  • IxIO
  • IxMonad
  • Monoidal
  • Pair
  • StrMap (use Record instead)
    StrMap (使用记录代替)
  • Trace
  • Validation (use Either’s getValidation)
    Validation (使用Either的 getValidation
  • Zipper

References   参考

If you’re interested in reading up on how this release came to be, have a look at the following discussions:
如果您有兴趣了解此版本的发布过程,请查看以下讨论:

Modules   模块

This section provides technical reference material for the functions, data types, and type classes provided by fp-ts.
本节提供 fp-ts 提供的函数、数据类型和类型类的技术参考资料。


Table of contents 目录

Alt overview  一切概览

The Alt type class identifies an associative operation on a type constructor. It is similar to Semigroup, except that it applies to types of kind * -> *, like Array or Option, rather than concrete types like string or number.
Alt 类型类标识类型构造函数上的关联操作。它与 Semigroup 类似,只不过它适用于 * -> * 类型,如 ArrayOption ,而不是具体类型,如 stringnumber

Alt instances are required to satisfy the following laws:
Alt 实例需要满足以下定律:

  1. Associativity: A.alt(A.alt(fa, ga), ha) <-> A.alt(fa, A.alt(ga, ha)) 关联性: A.alt(A.alt(fa, ga), ha) <-> A.alt(fa, A.alt(ga, ha))
  2. Distributivity: A.map(A.alt(fa, ga), ab) <-> A.alt(A.map(fa, ab), A.map(ga, ab)) 分布率: A.map(A.alt(fa, ga), ab) <-> A.alt(A.map(fa, ab), A.map(ga, ab))

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Alt (interface)   替代(界面)

Signature 签名

export interface Alt<F> extends Functor<F> {
  readonly alt: <A>(fa: HKT<F, A>, that: LazyArg<HKT<F, A>>) => HKT<F, A>
}

Added in v2.0.0 v2.0.0 中添加

Alt1 (interface)  Alt1(界面)

Signature 签名

export interface Alt1<F extends URIS> extends Functor1<F> {
  readonly alt: <A>(fa: Kind<F, A>, that: LazyArg<Kind<F, A>>) => Kind<F, A>
}

Added in v2.0.0 v2.0.0 中添加

Alt2 (interface)  Alt2(界面)

Signature 签名

export interface Alt2<F extends URIS2> extends Functor2<F> {
  readonly alt: <E, A>(fa: Kind2<F, E, A>, that: LazyArg<Kind2<F, E, A>>) => Kind2<F, E, A>
}

Added in v2.0.0 v2.0.0 中添加

Alt2C (interface)  Alt2C(接口)

Signature 签名

export interface Alt2C<F extends URIS2, E> extends Functor2C<F, E> {
  readonly alt: <A>(fa: Kind2<F, E, A>, that: LazyArg<Kind2<F, E, A>>) => Kind2<F, E, A>
}

Added in v2.0.0 v2.0.0 中添加

Alt3 (interface)  Alt3(界面)

Signature 签名

export interface Alt3<F extends URIS3> extends Functor3<F> {
  readonly alt: <R, E, A>(fa: Kind3<F, R, E, A>, that: LazyArg<Kind3<F, R, E, A>>) => Kind3<F, R, E, A>
}

Added in v2.0.0 v2.0.0 中添加

Alt3C (interface)  Alt3C(接口)

Signature 签名

export interface Alt3C<F extends URIS3, E> extends Functor3C<F, E> {
  readonly alt: <R, A>(fa: Kind3<F, R, E, A>, that: LazyArg<Kind3<F, R, E, A>>) => Kind3<F, R, E, A>
}

Added in v2.2.0 v2.2.0中添加

Alt4 (interface)  Alt4(界面)

Signature 签名

export interface Alt4<F extends URIS4> extends Functor4<F> {
  readonly alt: <S, R, E, A>(fa: Kind4<F, S, R, E, A>, that: LazyArg<Kind4<F, S, R, E, A>>) => Kind4<F, S, R, E, A>
}

Added in v2.0.0 v2.0.0 中添加

utils  实用程序

altAll   全部

Signature 签名

export declare function altAll<F extends URIS4>(
  F: Alt4<F>
): <S, R, E, A>(startWith: Kind4<F, S, R, E, A>) => (as: ReadonlyArray<Kind4<F, S, R, E, A>>) => Kind4<F, S, R, E, A>
export declare function altAll<F extends URIS3>(
  F: Alt3<F>
): <R, E, A>(startWith: Kind3<F, R, E, A>) => (as: ReadonlyArray<Kind3<F, R, E, A>>) => Kind3<F, R, E, A>
export declare function altAll<F extends URIS3, E>(
  F: Alt3C<F, E>
): <R, A>(startWith: Kind3<F, R, E, A>) => (as: ReadonlyArray<Kind3<F, R, E, A>>) => Kind3<F, R, E, A>
export declare function altAll<F extends URIS2>(
  F: Alt2<F>
): <E, A>(startWith: Kind2<F, E, A>) => (as: ReadonlyArray<Kind2<F, E, A>>) => Kind2<F, E, A>
export declare function altAll<F extends URIS2, E>(
  F: Alt2C<F, E>
): <A>(startWith: Kind2<F, E, A>) => (as: ReadonlyArray<Kind2<F, E, A>>) => Kind2<F, E, A>
export declare function altAll<F extends URIS>(
  F: Alt1<F>
): <A>(startWith: Kind<F, A>) => (as: ReadonlyArray<Kind<F, A>>) => Kind<F, A>
export declare function altAll<F>(F: Alt<F>): <A>(startWith: HKT<F, A>) => (as: ReadonlyArray<HKT<F, A>>) => HKT<F, A>

Added in v2.11.0 v2.11.0 中添加

Alternative overview   替代概述

The Alternative type class extends the Alt type class with a value that should be the left and right identity for alt.
Alternative 类型类扩展了 Alt 类型类,其值应该是 alt 的左右标识。

It is similar to Monoid, except that it applies to types of kind * -> *, like Array or Option, rather than concrete types like string or number.
它与 Monoid 类似,不同之处在于它适用于 * -> * 类型,如 ArrayOption ,而不是具体类型,如 stringnumber

Alternative instances should satisfy the following laws:
Alternative 实例应满足以下规律:

  1. Left identity: A.alt(zero, fa) <-> fa 左身份: A.alt(zero, fa) <-> fa
  2. Right identity: A.alt(fa, zero) <-> fa 正确身份: A.alt(fa, zero) <-> fa
  3. Annihilation: A.map(zero, f) <-> zero 湮灭: A.map(zero, f) <-> zero
  4. Distributivity: A.ap(A.alt(fab, gab), fa) <-> A.alt(A.ap(fab, fa), A.ap(gab, fa)) 分布率: A.ap(A.alt(fab, gab), fa) <-> A.alt(A.ap(fab, fa), A.ap(gab, fa))
  5. Annihilation: A.ap(zero, fa) <-> zero 湮灭: A.ap(zero, fa) <-> zero

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Alternative (interface)
替代方案(界面)

Signature 签名

export interface Alternative<F> extends Applicative<F>, Alt<F>, Zero<F> {}

Added in v2.0.0 v2.0.0 中添加

Alternative1 (interface)
替代方案1(界面)

Signature 签名

export interface Alternative1<F extends URIS> extends Applicative1<F>, Alt1<F>, Zero1<F> {}

Added in v2.0.0 v2.0.0 中添加

Alternative2 (interface)
替代方案2(界面)

Signature 签名

export interface Alternative2<F extends URIS2> extends Applicative2<F>, Alt2<F>, Zero2<F> {}

Added in v2.0.0 v2.0.0 中添加

Alternative2C (interface)
替代2C(接口)

Signature 签名

export interface Alternative2C<F extends URIS2, E> extends Applicative2C<F, E>, Alt2C<F, E>, Zero2C<F, E> {}

Added in v2.0.0 v2.0.0 中添加

Alternative3 (interface)
替代方案3(界面)

Signature 签名

export interface Alternative3<F extends URIS3> extends Applicative3<F>, Alt3<F>, Zero3<F> {}

Added in v2.0.0 v2.0.0 中添加

Alternative3C (interface)
替代3C(接口)

Signature 签名

export interface Alternative3C<F extends URIS3, E> extends Applicative3C<F, E>, Alt3C<F, E>, Zero3C<F, E> {}

Added in v2.10.0 v2.10.0 中添加

Alternative4 (interface)
替代方案4(界面)

Signature 签名

export interface Alternative4<F extends URIS4> extends Applicative4<F>, Alt4<F>, Zero4<F> {}

Added in v2.10.0 v2.10.0 中添加

utils   实用程序

altAll   全部

Signature 签名

export declare function altAll<F extends URIS4>(
  F: Alternative4<F>
): <S, R, E, A>(as: ReadonlyArray<Kind4<F, S, R, E, A>>) => Kind4<F, S, R, E, A>
export declare function altAll<F extends URIS3>(
  F: Alternative3<F>
): <R, E, A>(as: ReadonlyArray<Kind3<F, R, E, A>>) => Kind3<F, R, E, A>
export declare function altAll<F extends URIS3, E>(
  F: Alternative3C<F, E>
): <R, A>(as: ReadonlyArray<Kind3<F, R, E, A>>) => Kind3<F, R, E, A>
export declare function altAll<F extends URIS2>(
  F: Alternative2<F>
): <E, A>(as: ReadonlyArray<Kind2<F, E, A>>) => Kind2<F, E, A>
export declare function altAll<F extends URIS2, E>(
  F: Alternative2C<F, E>
): <A>(as: ReadonlyArray<Kind2<F, E, A>>) => Kind2<F, E, A>
export declare function altAll<F extends URIS>(F: Alternative1<F>): <A>(as: ReadonlyArray<Kind<F, A>>) => Kind<F, A>
export declare function altAll<F>(F: Alternative<F>): <A>(as: ReadonlyArray<HKT<F, A>>) => HKT<F, A>

Added in v2.11.0 v2.11.0 中添加

getAlternativeMonoid   获取替代幺半群

Lift a semigroup into a monoid alternative ‘F’, the inner values are concatenated using the provided Semigroup.
将半群提升为幺半群替代“F”,内部值使用提供的 Semigroup 连接。

Signature 签名

export declare function getAlternativeMonoid<F extends URIS4>(
  F: Alternative4<F>
): <A, S, R, E>(S: Semigroup<A>) => Monoid<Kind4<F, S, R, E, A>>
export declare function getAlternativeMonoid<F extends URIS3>(
  F: Alternative3<F>
): <A, R, E>(S: Semigroup<A>) => Monoid<Kind3<F, R, E, A>>
export declare function getAlternativeMonoid<F extends URIS3, E>(
  F: Alternative3C<F, E>
): <A, R>(S: Semigroup<A>) => Monoid<Kind3<F, R, E, A>>
export declare function getAlternativeMonoid<F extends URIS2>(
  F: Alternative2<F>
): <A, E>(S: Semigroup<A>) => Monoid<Kind2<F, E, A>>
export declare function getAlternativeMonoid<F extends URIS2, E>(
  F: Alternative2C<F, E>
): <A>(S: Semigroup<A>) => Monoid<Kind2<F, E, A>>
export declare function getAlternativeMonoid<F extends URIS>(
  F: Alternative1<F>
): <A>(S: Semigroup<A>) => Monoid<Kind<F, A>>
export declare function getAlternativeMonoid<F>(F: Alternative<F>): <A>(S: Semigroup<A>) => Monoid<HKT<F, A>>

Added in v2.13.0 v2.13.0 中添加

Applicative overview  应用概述

The Applicative type class extends the Apply type class with a of function, which can be used to create values of type f a from values of type a.
Applicative 类型类使用 of 函数扩展 Apply 类型类,该函数可用于从 a 类型的值创建 f a 类型的值。

Where Apply provides the ability to lift functions of two or more arguments to functions whose arguments are wrapped using f, and Functor provides the ability to lift functions of one argument, pure can be seen as the function which lifts functions of zero arguments. That is, Applicative functors support a lifting operation for any number of function arguments.
其中 Apply 提供了将两个或多个参数的函数提升到使用 f 包装参数的函数的能力,而 Functor 提供了提升一个参数的函数的能力, pure 可以看作是以下函数:提升零参数的函数。也就是说, Applicative 函子支持任意数量的函数参数的提升操作。

Instances must satisfy the following laws in addition to the Apply laws:
除了 Apply 法则之外,实例还必须满足以下法则:

  1. Identity: A.ap(A.of(a => a), fa) <-> fa 身份: A.ap(A.of(a => a), fa) <-> fa
  2. Homomorphism: A.ap(A.of(ab), A.of(a)) <-> A.of(ab(a)) 同态: A.ap(A.of(ab), A.of(a)) <-> A.of(ab(a))
  3. Interchange: A.ap(fab, A.of(a)) <-> A.ap(A.of(ab => ab(a)), fab) 交换: A.ap(fab, A.of(a)) <-> A.ap(A.of(ab => ab(a)), fab)

Note. Functor’s map can be derived: A.map(x, f) = A.ap(A.of(f), x)
笔记。 Functor 的@​​1#可以推导出: A.map(x, f) = A.ap(A.of(f), x)

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Applicative (interface)
应用(界面)

Signature 签名

export interface Applicative<F> extends Apply<F>, Pointed<F> {}

Added in v2.0.0 v2.0.0 中添加

Applicative1 (interface)
应用1(界面)

Signature 签名

export interface Applicative1<F extends URIS> extends Apply1<F>, Pointed1<F> {}

Added in v2.0.0 v2.0.0 中添加

Applicative2 (interface)
应用2(界面)

Signature 签名

export interface Applicative2<F extends URIS2> extends Apply2<F>, Pointed2<F> {}

Added in v2.0.0 v2.0.0 中添加

Applicative2C (interface)
应用2C(接口)

Signature 签名

export interface Applicative2C<F extends URIS2, E> extends Apply2C<F, E>, Pointed2C<F, E> {}

Added in v2.0.0 v2.0.0 中添加

Applicative3 (interface)
应用3(界面)

Signature 签名

export interface Applicative3<F extends URIS3> extends Apply3<F>, Pointed3<F> {}

Added in v2.0.0 v2.0.0 中添加

Applicative3C (interface)
应用3C(接口)

Signature 签名

export interface Applicative3C<F extends URIS3, E> extends Apply3C<F, E>, Pointed3C<F, E> {}

Added in v2.2.0 v2.2.0中添加

Applicative4 (interface)
应用4(界面)

Signature 签名

export interface Applicative4<F extends URIS4> extends Apply4<F>, Pointed4<F> {}

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

getApplicativeMonoid   getApplicativeMonoid

Lift a monoid into ‘F’, the inner values are concatenated using the provided Monoid.
将幺半群提升为“F”,内部值使用提供的 Monoid 连接。

Signature 签名

export declare function getApplicativeMonoid<F extends URIS4>(
  F: Applicative4<F>
): <A, S, R, E>(M: Monoid<A>) => Monoid<Kind4<F, S, R, E, A>>
export declare function getApplicativeMonoid<F extends URIS3>(
  F: Applicative3<F>
): <A, R, E>(M: Monoid<A>) => Monoid<Kind3<F, R, E, A>>
export declare function getApplicativeMonoid<F extends URIS3, E>(
  F: Applicative3C<F, E>
): <A, R>(M: Monoid<A>) => Monoid<Kind3<F, R, E, A>>
export declare function getApplicativeMonoid<F extends URIS2>(
  F: Applicative2<F>
): <A, E>(M: Monoid<A>) => Monoid<Kind2<F, E, A>>
export declare function getApplicativeMonoid<F extends URIS2, E>(
  F: Applicative2C<F, E>
): <A>(M: Monoid<A>) => Monoid<Kind2<F, E, A>>
export declare function getApplicativeMonoid<F extends URIS>(
  F: Applicative1<F>
): <A>(M: Monoid<A>) => Monoid<Kind<F, A>>
export declare function getApplicativeMonoid<F>(F: Applicative<F>): <A>(M: Monoid<A>) => Monoid<HKT<F, A>>

Added in v2.10.0 v2.10.0 中添加

zone of death
死亡地带

ApplicativeComposition11
应用作文11
(interface)   (界面)

Signature 签名

export interface ApplicativeComposition11<F extends URIS, G extends URIS> extends FunctorComposition11<F, G> {
  readonly of: <A>(a: A) => Kind<F, Kind<G, A>>
  readonly ap: <A, B>(fgab: Kind<F, Kind<G, (a: A) => B>>, fga: Kind<F, Kind<G, A>>) => Kind<F, Kind<G, B>>
}

Added in v2.0.0 v2.0.0 中添加

ApplicativeComposition12C
应用作文12C
(interface)   (界面)

Signature 签名

export interface ApplicativeComposition12C<F extends URIS, G extends URIS2, E> extends FunctorComposition12C<F, G, E> {
  readonly of: <A>(a: A) => Kind<F, Kind2<G, E, A>>
  readonly ap: <A, B>(fgab: Kind<F, Kind2<G, E, (a: A) => B>>, fga: Kind<F, Kind2<G, E, A>>) => Kind<F, Kind2<G, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

ApplicativeComposition12
应用作文12
(interface)   (界面)

Signature 签名

export interface ApplicativeComposition12<F extends URIS, G extends URIS2> extends FunctorComposition12<F, G> {
  readonly of: <E, A>(a: A) => Kind<F, Kind2<G, E, A>>
  readonly ap: <E, A, B>(
    fgab: Kind<F, Kind2<G, E, (a: A) => B>>,
    fga: Kind<F, Kind2<G, E, A>>
  ) => Kind<F, Kind2<G, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

ApplicativeComposition21
应用作文21
(interface)   (界面)

Signature 签名

export interface ApplicativeComposition21<F extends URIS2, G extends URIS> extends FunctorComposition21<F, G> {
  readonly of: <E, A>(a: A) => Kind2<F, E, Kind<G, A>>
  readonly ap: <E, A, B>(
    fgab: Kind2<F, E, Kind<G, (a: A) => B>>,
    fga: Kind2<F, E, Kind<G, A>>
  ) => Kind2<F, E, Kind<G, B>>
}

Added in v2.0.0 v2.0.0 中添加

ApplicativeComposition22C
应用作文22C
(interface)   (界面)

Signature 签名

export interface ApplicativeComposition22C<F extends URIS2, G extends URIS2, E> extends FunctorComposition22C<F, G, E> {
  readonly of: <FE, A>(a: A) => Kind2<F, FE, Kind2<G, E, A>>
  readonly ap: <FE, A, B>(
    fgab: Kind2<F, FE, Kind2<G, E, (a: A) => B>>,
    fga: Kind2<F, FE, Kind2<G, E, A>>
  ) => Kind2<F, FE, Kind2<G, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

ApplicativeComposition22
应用作文22
(interface)   (界面)

Signature 签名

export interface ApplicativeComposition22<F extends URIS2, G extends URIS2> extends FunctorComposition22<F, G> {
  readonly of: <FE, GE, A>(a: A) => Kind2<F, FE, Kind2<G, GE, A>>
  readonly ap: <FE, GE, A, B>(
    fgab: Kind2<F, FE, Kind2<G, GE, (a: A) => B>>,
    fga: Kind2<F, FE, Kind2<G, GE, A>>
  ) => Kind2<F, FE, Kind2<G, GE, B>>
}

Added in v2.0.0 v2.0.0 中添加

ApplicativeComposition2C1
应用作文2C1
(interface)   (界面)

Signature 签名

export interface ApplicativeComposition2C1<F extends URIS2, G extends URIS, E> extends FunctorComposition2C1<F, G, E> {
  readonly of: <A>(a: A) => Kind2<F, E, Kind<G, A>>
  readonly ap: <A, B>(fgab: Kind2<F, E, Kind<G, (a: A) => B>>, fga: Kind2<F, E, Kind<G, A>>) => Kind2<F, E, Kind<G, B>>
}

Added in v2.0.0 v2.0.0 中添加

ApplicativeCompositionHKT1
应用作文HKT1
(interface)   (界面)

Signature 签名

export interface ApplicativeCompositionHKT1<F, G extends URIS> extends FunctorCompositionHKT1<F, G> {
  readonly of: <A>(a: A) => HKT<F, Kind<G, A>>
  readonly ap: <A, B>(fgab: HKT<F, Kind<G, (a: A) => B>>, fga: HKT<F, Kind<G, A>>) => HKT<F, Kind<G, B>>
}

Added in v2.0.0 v2.0.0 中添加

ApplicativeCompositionHKT2C
应用作文HKT2C
(interface)   (界面)

Signature 签名

export interface ApplicativeCompositionHKT2C<F, G extends URIS2, E> extends FunctorCompositionHKT2C<F, G, E> {
  readonly of: <A>(a: A) => HKT<F, Kind2<G, E, A>>
  readonly ap: <A, B>(fgab: HKT<F, Kind2<G, E, (a: A) => B>>, fga: HKT<F, Kind2<G, E, A>>) => HKT<F, Kind2<G, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

ApplicativeCompositionHKT2
应用作文HKT2
(interface)   (界面)

Signature 签名

export interface ApplicativeCompositionHKT2<F, G extends URIS2> extends FunctorCompositionHKT2<F, G> {
  readonly of: <E, A>(a: A) => HKT<F, Kind2<G, E, A>>
  readonly ap: <E, A, B>(fgab: HKT<F, Kind2<G, E, (a: A) => B>>, fga: HKT<F, Kind2<G, E, A>>) => HKT<F, Kind2<G, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

ApplicativeComposition 应用作文 (interface)   (界面)

Signature 签名

export interface ApplicativeComposition<F, G> extends FunctorComposition<F, G> {
  readonly of: <A>(a: A) => HKT<F, HKT<G, A>>
  readonly ap: <A, B>(fgab: HKT<F, HKT<G, (a: A) => B>>, fga: HKT<F, HKT<G, A>>) => HKT<F, HKT<G, B>>
}

Added in v2.0.0 v2.0.0 中添加

getApplicativeComposition
获取应用成分

Use ap instead. 请改用 ap

Signature 签名

export declare function getApplicativeComposition<F extends URIS2, G extends URIS2, E>(
  F: Applicative2<F>,
  G: Applicative2C<G, E>
): ApplicativeComposition22C<F, G, E>
export declare function getApplicativeComposition<F extends URIS2, G extends URIS2>(
  F: Applicative2<F>,
  G: Applicative2<G>
): ApplicativeComposition22<F, G>
export declare function getApplicativeComposition<F extends URIS2, G extends URIS2, E>(
  F: Applicative2<F>,
  G: Applicative2C<G, E>
): ApplicativeComposition22C<F, G, E>
export declare function getApplicativeComposition<F extends URIS2, G extends URIS>(
  F: Applicative2<F>,
  G: Applicative1<G>
): ApplicativeComposition21<F, G>
export declare function getApplicativeComposition<F extends URIS, G extends URIS2>(
  F: Applicative1<F>,
  G: Applicative2<G>
): ApplicativeComposition12<F, G>
export declare function getApplicativeComposition<F extends URIS, G extends URIS2, E>(
  F: Applicative1<F>,
  G: Applicative2C<G, E>
): ApplicativeComposition12C<F, G, E>
export declare function getApplicativeComposition<F extends URIS, G extends URIS>(
  F: Applicative1<F>,
  G: Applicative1<G>
): ApplicativeComposition11<F, G>
export declare function getApplicativeComposition<F, G extends URIS2>(
  F: Applicative<F>,
  G: Applicative2<G>
): ApplicativeCompositionHKT2<F, G>
export declare function getApplicativeComposition<F, G extends URIS2, E>(
  F: Applicative<F>,
  G: Applicative2C<G, E>
): ApplicativeCompositionHKT2C<F, G, E>
export declare function getApplicativeComposition<F, G extends URIS>(
  F: Applicative<F>,
  G: Applicative1<G>
): ApplicativeCompositionHKT1<F, G>
export declare function getApplicativeComposition<F, G>(
  F: Applicative<F>,
  G: Applicative<G>
): ApplicativeComposition<F, G>

Added in v2.0.0 v2.0.0 中添加

Apply overview  应用概览

The Apply class provides the ap which is used to apply a function to an argument under a type constructor.
Apply 类提供 ap ,用于将函数应用于类型构造函数下的参数。

Apply can be used to lift functions of two or more arguments to work on values wrapped with the type constructor f.
Apply 可用于提升两个或多个参数的函数,以处理使用类型构造函数 f 包装的值。

Instances must satisfy the following law in addition to the Functor laws:
除了 Functor 法则之外,实例还必须满足以下法则:

  1. Associative composition: F.ap(F.ap(F.map(fbc, bc => ab => a => bc(ab(a))), fab), fa) <-> F.ap(fbc, F.ap(fab, fa))
    联想组合: F.ap(F.ap(F.map(fbc, bc => ab => a => bc(ab(a))), fab), fa) <-> F.ap(fbc, F.ap(fab, fa))

Formally, Apply represents a strong lax semi-monoidal endofunctor.
形式上, Apply 代表强松弛半幺半形内函子。

Example 例子

import * as O from 'fp-ts/Option'
import { pipe } from 'fp-ts/function'

const f = (a: string) => (b: number) => (c: boolean) => a + String(b) + String(c)
const fa: O.Option<string> = O.some('s')
const fb: O.Option<number> = O.some(1)
const fc: O.Option<boolean> = O.some(true)

assert.deepStrictEqual(
  pipe(
    // lift a function
    O.some(f),
    // apply the first argument
    O.ap(fa),
    // apply the second argument
    O.ap(fb),
    // apply the third argument
    O.ap(fc)
  ),
  O.some('s1true')
)

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Apply (interface)   应用(界面)

Signature 签名

export interface Apply<F> extends Functor<F> {
  readonly ap: <A, B>(fab: HKT<F, (a: A) => B>, fa: HKT<F, A>) => HKT<F, B>
}

Added in v2.0.0 v2.0.0 中添加

Apply1 (interface)   应用1(接口)

Signature 签名

export interface Apply1<F extends URIS> extends Functor1<F> {
  readonly ap: <A, B>(fab: Kind<F, (a: A) => B>, fa: Kind<F, A>) => Kind<F, B>
}

Added in v2.0.0 v2.0.0 中添加

Apply2 (interface)   应用2(接口)

Signature 签名

export interface Apply2<F extends URIS2> extends Functor2<F> {
  readonly ap: <E, A, B>(fab: Kind2<F, E, (a: A) => B>, fa: Kind2<F, E, A>) => Kind2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

Apply2C (interface)   应用2C(接口)

Signature 签名

export interface Apply2C<F extends URIS2, E> extends Functor2C<F, E> {
  readonly ap: <A, B>(fab: Kind2<F, E, (a: A) => B>, fa: Kind2<F, E, A>) => Kind2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

Apply3 (interface)   应用3(接口)

Signature 签名

export interface Apply3<F extends URIS3> extends Functor3<F> {
  readonly ap: <R, E, A, B>(fab: Kind3<F, R, E, (a: A) => B>, fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
}

Added in v2.0.0 v2.0.0 中添加

Apply3C (interface)   应用3C(接口)

Signature 签名

export interface Apply3C<F extends URIS3, E> extends Functor3C<F, E> {
  readonly ap: <R, A, B>(fab: Kind3<F, R, E, (a: A) => B>, fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
}

Added in v2.2.0 v2.2.0中添加

Apply4 (interface)   应用4(接口)

Signature 签名

export interface Apply4<F extends URIS4> extends Functor4<F> {
  readonly ap: <S, R, E, A, B>(fab: Kind4<F, S, R, E, (a: A) => B>, fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>
}

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

ap   美联社

ap composition.

Signature 签名

export declare function ap<F extends URIS4, G extends URIS4>(
  F: Apply4<F>,
  G: Apply4<G>
): <FS, FR, FE, GS, GR, GE, A>(
  fa: Kind4<F, FS, FR, FE, Kind4<G, GS, GR, GE, A>>
) => <B>(fab: Kind4<F, FS, FR, FE, Kind4<G, GS, GR, GE, (a: A) => B>>) => Kind4<F, FS, FR, FE, Kind4<G, GS, GR, GE, B>>
export declare function ap<F extends URIS4, G extends URIS3>(
  F: Apply4<F>,
  G: Apply3<G>
): <S, FR, FE, GR, GE, A>(
  fa: Kind4<F, S, FR, FE, Kind3<G, GR, GE, A>>
) => <B>(fab: Kind4<F, S, FR, FE, Kind3<G, GR, GE, (a: A) => B>>) => Kind4<F, S, FR, FE, Kind3<G, GR, GE, B>>
export declare function ap<F extends URIS4, G extends URIS3, GE>(
  F: Apply4<F>,
  G: Apply3C<G, GE>
): <S, FR, FE, GR, A>(
  fa: Kind4<F, S, FR, FE, Kind3<G, GR, GE, A>>
) => <B>(fab: Kind4<F, S, FR, FE, Kind3<G, GR, GE, (a: A) => B>>) => Kind4<F, S, FR, FE, Kind3<G, GR, GE, B>>
export declare function ap<F extends URIS4, G extends URIS2>(
  F: Apply4<F>,
  G: Apply2<G>
): <S, R, FE, GE, A>(
  fa: Kind4<F, S, R, FE, Kind2<G, GE, A>>
) => <B>(fab: Kind4<F, S, R, FE, Kind2<G, GE, (a: A) => B>>) => Kind4<F, S, R, FE, Kind2<G, GE, B>>
export declare function ap<F extends URIS4, G extends URIS2, GE>(
  F: Apply4<F>,
  G: Apply2C<G, GE>
): <S, R, FE, A>(
  fa: Kind4<F, S, R, FE, Kind2<G, GE, A>>
) => <B>(fab: Kind4<F, S, R, FE, Kind2<G, GE, (a: A) => B>>) => Kind4<F, S, R, FE, Kind2<G, GE, B>>
export declare function ap<F extends URIS4, G extends URIS>(
  F: Apply4<F>,
  G: Apply1<G>
): <S, R, E, A>(
  fa: Kind4<F, S, R, E, Kind<G, A>>
) => <B>(fab: Kind4<F, S, R, E, Kind<G, (a: A) => B>>) => Kind4<F, S, R, E, Kind<G, B>>
export declare function ap<F extends URIS3, FE, G extends URIS4>(
  F: Apply3C<F, FE>,
  G: Apply4<G>
): <FR, S, GR, GE, A>(
  fa: Kind3<F, FR, FE, Kind4<G, S, GR, GE, A>>
) => <B>(fab: Kind3<F, FR, FE, Kind4<G, S, GR, GE, (a: A) => B>>) => Kind3<F, FR, FE, Kind4<G, S, GR, GE, B>>
export declare function ap<F extends URIS3, FE, G extends URIS3>(
  F: Apply3C<F, FE>,
  G: Apply3<G>
): <FR, GR, GE, A>(
  fa: Kind3<F, FR, FE, Kind3<G, GR, GE, A>>
) => <B>(fab: Kind3<F, FR, FE, Kind3<G, GR, GE, (a: A) => B>>) => Kind3<F, FR, FE, Kind3<G, GR, GE, B>>
export declare function ap<F extends URIS3, FE, G extends URIS3, GE>(
  F: Apply3C<F, FE>,
  G: Apply3C<G, GE>
): <FR, GR, A>(
  fa: Kind3<F, FR, FE, Kind3<G, GR, GE, A>>
) => <B>(fab: Kind3<F, FR, FE, Kind3<G, GR, GE, (a: A) => B>>) => Kind3<F, FR, FE, Kind3<G, GR, GE, B>>
export declare function ap<F extends URIS3, FE, G extends URIS2>(
  F: Apply3C<F, FE>,
  G: Apply2<G>
): <R, GE, A>(
  fa: Kind3<F, R, FE, Kind2<G, GE, A>>
) => <B>(fab: Kind3<F, R, FE, Kind2<G, GE, (a: A) => B>>) => Kind3<F, R, FE, Kind2<G, GE, B>>
export declare function ap<F extends URIS3, FE, G extends URIS2, GE>(
  F: Apply3C<F, FE>,
  G: Apply2C<G, GE>
): <R, A>(
  fa: Kind3<F, R, FE, Kind2<G, GE, A>>
) => <B>(fab: Kind3<F, R, FE, Kind2<G, GE, (a: A) => B>>) => Kind3<F, R, FE, Kind2<G, GE, B>>
export declare function ap<F extends URIS3, E, G extends URIS>(
  F: Apply3C<F, E>,
  G: Apply1<G>
): <R, A>(
  fa: Kind3<F, R, E, Kind<G, A>>
) => <B>(fab: Kind3<F, R, E, Kind<G, (a: A) => B>>) => Kind3<F, R, E, Kind<G, B>>
export declare function ap<F extends URIS3, G extends URIS4>(
  F: Apply3<F>,
  G: Apply4<G>
): <FR, FE, S, GR, GE, A>(
  fa: Kind3<F, FR, FE, Kind4<G, S, GR, GE, A>>
) => <B>(fab: Kind3<F, FR, FE, Kind4<G, S, GR, GE, (a: A) => B>>) => Kind3<F, FR, FE, Kind4<G, S, GR, GE, B>>
export declare function ap<F extends URIS3, G extends URIS3>(
  F: Apply3<F>,
  G: Apply3<G>
): <FR, FE, GR, GE, A>(
  fa: Kind3<F, FR, FE, Kind3<G, GR, GE, A>>
) => <B>(fab: Kind3<F, FR, FE, Kind3<G, GR, GE, (a: A) => B>>) => Kind3<F, FR, FE, Kind3<G, GR, GE, B>>
export declare function ap<F extends URIS3, G extends URIS3, GE>(
  F: Apply3<F>,
  G: Apply3C<G, GE>
): <FR, FE, GR, A>(
  fa: Kind3<F, FR, FE, Kind3<G, GR, GE, A>>
) => <B>(fab: Kind3<F, FR, FE, Kind3<G, GR, GE, (a: A) => B>>) => Kind3<F, FR, FE, Kind3<G, GR, GE, B>>
export declare function ap<F extends URIS3, G extends URIS2>(
  F: Apply3<F>,
  G: Apply2<G>
): <R, FE, GE, A>(
  fa: Kind3<F, R, FE, Kind2<G, GE, A>>
) => <B>(fab: Kind3<F, R, FE, Kind2<G, GE, (a: A) => B>>) => Kind3<F, R, FE, Kind2<G, GE, B>>
export declare function ap<F extends URIS3, G extends URIS2, GE>(
  F: Apply3<F>,
  G: Apply2C<G, GE>
): <R, FE, A>(
  fa: Kind3<F, R, FE, Kind2<G, GE, A>>
) => <B>(fab: Kind3<F, R, FE, Kind2<G, GE, (a: A) => B>>) => Kind3<F, R, FE, Kind2<G, GE, B>>
export declare function ap<F extends URIS3, G extends URIS>(
  F: Apply3<F>,
  G: Apply1<G>
): <R, E, A>(
  fa: Kind3<F, R, E, Kind<G, A>>
) => <B>(fab: Kind3<F, R, E, Kind<G, (a: A) => B>>) => Kind3<F, R, E, Kind<G, B>>
export declare function ap<F extends URIS2, FE, G extends URIS4>(
  F: Apply2C<F, FE>,
  G: Apply4<G>
): <S, R, GE, A>(
  fa: Kind2<F, FE, Kind4<G, S, R, GE, A>>
) => <B>(fab: Kind2<F, FE, Kind4<G, S, R, GE, (a: A) => B>>) => Kind2<F, FE, Kind4<G, S, R, GE, B>>
export declare function ap<F extends URIS2, FE, G extends URIS3>(
  F: Apply2C<F, FE>,
  G: Apply3<G>
): <R, GE, A>(
  fa: Kind2<F, FE, Kind3<G, R, GE, A>>
) => <B>(fab: Kind2<F, FE, Kind3<G, R, GE, (a: A) => B>>) => Kind2<F, FE, Kind3<G, R, GE, B>>
export declare function ap<F extends URIS2, FE, G extends URIS3, GE>(
  F: Apply2C<F, FE>,
  G: Apply3C<G, GE>
): <R, A>(
  fa: Kind2<F, FE, Kind3<G, R, GE, A>>
) => <B>(fab: Kind2<F, FE, Kind3<G, R, GE, (a: A) => B>>) => Kind2<F, FE, Kind3<G, R, GE, B>>
export declare function ap<F extends URIS2, FE, G extends URIS2>(
  F: Apply2C<F, FE>,
  G: Apply2<G>
): <GE, A>(
  fa: Kind2<F, FE, Kind2<G, GE, A>>
) => <B>(fab: Kind2<F, FE, Kind2<G, GE, (a: A) => B>>) => Kind2<F, FE, Kind2<G, GE, B>>
export declare function ap<F extends URIS2, FE, G extends URIS2, GE>(
  F: Apply2C<F, FE>,
  G: Apply2C<G, GE>
): <A>(
  fa: Kind2<F, FE, Kind2<G, GE, A>>
) => <B>(fab: Kind2<F, FE, Kind2<G, GE, (a: A) => B>>) => Kind2<F, FE, Kind2<G, GE, B>>
export declare function ap<F extends URIS2, E, G extends URIS>(
  F: Apply2C<F, E>,
  G: Apply1<G>
): <A>(fa: Kind2<F, E, Kind<G, A>>) => <B>(fab: Kind2<F, E, Kind<G, (a: A) => B>>) => Kind2<F, E, Kind<G, B>>
export declare function ap<F extends URIS2, G extends URIS4>(
  F: Apply2<F>,
  G: Apply4<G>
): <FE, S, R, GE, A>(
  fa: Kind2<F, FE, Kind4<G, S, R, GE, A>>
) => <B>(fab: Kind2<F, FE, Kind4<G, S, R, GE, (a: A) => B>>) => Kind2<F, FE, Kind4<G, S, R, GE, B>>
export declare function ap<F extends URIS2, G extends URIS3>(
  F: Apply2<F>,
  G: Apply3<G>
): <FE, R, GE, A>(
  fa: Kind2<F, FE, Kind3<G, R, GE, A>>
) => <B>(fab: Kind2<F, FE, Kind3<G, R, GE, (a: A) => B>>) => Kind2<F, FE, Kind3<G, R, GE, B>>
export declare function ap<F extends URIS2, G extends URIS3, GE>(
  F: Apply2<F>,
  G: Apply3C<G, GE>
): <FE, R, A>(
  fa: Kind2<F, FE, Kind3<G, R, GE, A>>
) => <B>(fab: Kind2<F, FE, Kind3<G, R, GE, (a: A) => B>>) => Kind2<F, FE, Kind3<G, R, GE, B>>
export declare function ap<F extends URIS2, G extends URIS2>(
  F: Apply2<F>,
  G: Apply2<G>
): <FE, GE, A>(
  fa: Kind2<F, FE, Kind2<G, GE, A>>
) => <B>(fab: Kind2<F, FE, Kind2<G, GE, (a: A) => B>>) => Kind2<F, FE, Kind2<G, GE, B>>
export declare function ap<F extends URIS2, G extends URIS2, GE>(
  F: Apply2<F>,
  G: Apply2C<G, GE>
): <FE, A>(
  fa: Kind2<F, FE, Kind2<G, GE, A>>
) => <B>(fab: Kind2<F, FE, Kind2<G, GE, (a: A) => B>>) => Kind2<F, FE, Kind2<G, GE, B>>
export declare function ap<F extends URIS2, G extends URIS>(
  F: Apply2<F>,
  G: Apply1<G>
): <E, A>(fa: Kind2<F, E, Kind<G, A>>) => <B>(fab: Kind2<F, E, Kind<G, (a: A) => B>>) => Kind2<F, E, Kind<G, B>>
export declare function ap<F extends URIS, G extends URIS4>(
  F: Apply1<F>,
  G: Apply4<G>
): <S, R, E, A>(
  fa: Kind<F, Kind4<G, S, R, E, A>>
) => <B>(fab: Kind<F, Kind4<G, S, R, E, (a: A) => B>>) => Kind<F, Kind4<G, S, R, E, B>>
export declare function ap<F extends URIS, G extends URIS3>(
  F: Apply1<F>,
  G: Apply3<G>
): <R, E, A>(
  fa: Kind<F, Kind3<G, R, E, A>>
) => <B>(fab: Kind<F, Kind3<G, R, E, (a: A) => B>>) => Kind<F, Kind3<G, R, E, B>>
export declare function ap<F extends URIS, G extends URIS3, E>(
  F: Apply1<F>,
  G: Apply3C<G, E>
): <R, A>(
  fa: Kind<F, Kind3<G, R, E, A>>
) => <B>(fab: Kind<F, Kind3<G, R, E, (a: A) => B>>) => Kind<F, Kind3<G, R, E, B>>
export declare function ap<F extends URIS, G extends URIS2>(
  F: Apply1<F>,
  G: Apply2<G>
): <E, A>(fa: Kind<F, Kind2<G, E, A>>) => <B>(fab: Kind<F, Kind2<G, E, (a: A) => B>>) => Kind<F, Kind2<G, E, B>>
export declare function ap<F extends URIS, G extends URIS2, E>(
  F: Apply1<F>,
  G: Apply2C<G, E>
): <A>(fa: Kind<F, Kind2<G, E, A>>) => <B>(fab: Kind<F, Kind2<G, E, (a: A) => B>>) => Kind<F, Kind2<G, E, B>>
export declare function ap<F extends URIS, G extends URIS>(
  F: Apply1<F>,
  G: Apply1<G>
): <A>(fa: Kind<F, Kind<G, A>>) => <B>(fab: Kind<F, Kind<G, (a: A) => B>>) => Kind<F, Kind<G, B>>
export declare function ap<F, G extends URIS4>(
  F: Apply<F>,
  G: Apply4<G>
): <S, R, E, A>(
  fa: HKT<F, Kind4<G, S, R, E, A>>
) => <B>(fab: HKT<F, Kind4<G, S, R, E, (a: A) => B>>) => HKT<F, Kind4<G, S, R, E, B>>
export declare function ap<F, G extends URIS3>(
  F: Apply<F>,
  G: Apply3<G>
): <R, E, A>(
  fa: HKT<F, Kind3<G, R, E, A>>
) => <B>(fab: HKT<F, Kind3<G, R, E, (a: A) => B>>) => HKT<F, Kind3<G, R, E, B>>
export declare function ap<F, G extends URIS3, E>(
  F: Apply<F>,
  G: Apply3C<G, E>
): <R, A>(fa: HKT<F, Kind3<G, R, E, A>>) => <B>(fab: HKT<F, Kind3<G, R, E, (a: A) => B>>) => HKT<F, Kind3<G, R, E, B>>
export declare function ap<F, G extends URIS2>(
  F: Apply<F>,
  G: Apply2<G>
): <E, A>(fa: HKT<F, Kind2<G, E, A>>) => <B>(fab: HKT<F, Kind2<G, E, (a: A) => B>>) => HKT<F, Kind2<G, E, B>>
export declare function ap<F, G extends URIS2, E>(
  F: Apply<F>,
  G: Apply2C<G, E>
): <A>(fa: HKT<F, Kind2<G, E, A>>) => <B>(fab: HKT<F, Kind2<G, E, (a: A) => B>>) => HKT<F, Kind2<G, E, B>>
export declare function ap<F, G extends URIS>(
  F: Apply<F>,
  G: Apply1<G>
): <A>(fa: HKT<F, Kind<G, A>>) => <B>(fab: HKT<F, Kind<G, (a: A) => B>>) => HKT<F, Kind<G, B>>
export declare function ap<F, G>(
  F: Apply<F>,
  G: Apply<G>
): <A>(fa: HKT<F, HKT<G, A>>) => <B>(fab: HKT<F, HKT<G, (a: A) => B>>) => HKT<F, HKT<G, B>>

Added in v2.10.0 v2.10.0 中添加

apFirst   应用程序第一

Signature 签名

export declare function apFirst<F extends URIS4>(
  A: Apply4<F>
): <S, R, E, B>(second: Kind4<F, S, R, E, B>) => <A>(first: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>
export declare function apFirst<F extends URIS3>(
  A: Apply3<F>
): <R, E, B>(second: Kind3<F, R, E, B>) => <A>(first: Kind3<F, R, E, A>) => Kind3<F, R, E, A>
export declare function apFirst<F extends URIS3, E>(
  A: Apply3C<F, E>
): <R, B>(second: Kind3<F, R, E, B>) => <A>(first: Kind3<F, R, E, A>) => Kind3<F, R, E, A>
export declare function apFirst<F extends URIS2>(
  A: Apply2<F>
): <E, B>(second: Kind2<F, E, B>) => <A>(first: Kind2<F, E, A>) => Kind2<F, E, A>
export declare function apFirst<F extends URIS2, E>(
  A: Apply2C<F, E>
): <B>(second: Kind2<F, E, B>) => <A>(first: Kind2<F, E, A>) => Kind2<F, E, A>
export declare function apFirst<F extends URIS>(
  A: Apply1<F>
): <B>(second: Kind<F, B>) => <A>(first: Kind<F, A>) => Kind<F, A>
export declare function apFirst<F>(A: Apply<F>): <B>(second: HKT<F, B>) => <A>(first: HKT<F, A>) => HKT<F, A>

Added in v2.10.0 v2.10.0 中添加

apS   apS

Signature 签名

export declare function apS<F extends URIS4>(
  F: Apply4<F>
): <N extends string, A, S, R, E, B>(
  name: Exclude<N, keyof A>,
  fb: Kind4<F, S, R, E, B>
) => (fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>
export declare function apS<F extends URIS3>(
  F: Apply3<F>
): <N extends string, A, R, E, B>(
  name: Exclude<N, keyof A>,
  fb: Kind3<F, R, E, B>
) => (fa: Kind3<F, R, E, A>) => Kind3<F, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>
export declare function apS<F extends URIS3, E>(
  F: Apply3C<F, E>
): <N extends string, A, R, B>(
  name: Exclude<N, keyof A>,
  fb: Kind3<F, R, E, B>
) => (fa: Kind3<F, R, E, A>) => Kind3<F, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>
export declare function apS<F extends URIS2>(
  F: Apply2<F>
): <N extends string, A, E, B>(
  name: Exclude<N, keyof A>,
  fb: Kind2<F, E, B>
) => (fa: Kind2<F, E, A>) => Kind2<F, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>
export declare function apS<F extends URIS2, E>(
  F: Apply2C<F, E>
): <N extends string, A, B>(
  name: Exclude<N, keyof A>,
  fb: Kind2<F, E, B>
) => (fa: Kind2<F, E, A>) => Kind2<F, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>
export declare function apS<F extends URIS>(
  F: Apply1<F>
): <N extends string, A, B>(
  name: Exclude<N, keyof A>,
  fb: Kind<F, B>
) => (fa: Kind<F, A>) => Kind<F, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>
export declare function apS<F>(
  F: Apply<F>
): <N extends string, A, B>(
  name: Exclude<N, keyof A>,
  fb: HKT<F, B>
) => (fa: HKT<F, A>) => HKT<F, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>

Added in v2.10.0 v2.10.0 中添加

apSecond   ap秒

Signature 签名

export declare function apSecond<F extends URIS4>(
  A: Apply4<F>
): <S, R, E, B>(second: Kind4<F, S, R, E, B>) => <A>(first: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>
export declare function apSecond<F extends URIS3>(
  A: Apply3<F>
): <R, E, B>(second: Kind3<F, R, E, B>) => <A>(first: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
export declare function apSecond<F extends URIS3, E>(
  A: Apply3C<F, E>
): <R, B>(second: Kind3<F, R, E, B>) => <A>(first: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
export declare function apSecond<F extends URIS2>(
  A: Apply2<F>
): <E, B>(second: Kind2<F, E, B>) => <A>(first: Kind2<F, E, A>) => Kind2<F, E, B>
export declare function apSecond<F extends URIS2, E>(
  A: Apply2C<F, E>
): <B>(second: Kind2<F, E, B>) => <A>(first: Kind2<F, E, A>) => Kind2<F, E, B>
export declare function apSecond<F extends URIS>(
  A: Apply1<F>
): <B>(second: Kind<F, B>) => <A>(first: Kind<F, A>) => Kind<F, B>
export declare function apSecond<F>(A: Apply<F>): <B>(second: HKT<F, B>) => <A>(first: HKT<F, A>) => HKT<F, B>

Added in v2.10.0 v2.10.0 中添加

getApplySemigroup   获取ApplySemigroup

Lift a semigroup into ‘F’, the inner values are concatenated using the provided Semigroup.
将半群提升为“F”,内部值使用提供的 Semigroup 连接。

Signature 签名

export declare function getApplySemigroup<F extends URIS4>(
  F: Apply4<F>
): <A, S, R, E>(S: Semigroup<A>) => Semigroup<Kind4<F, S, R, E, A>>
export declare function getApplySemigroup<F extends URIS3>(
  F: Apply3<F>
): <A, R, E>(S: Semigroup<A>) => Semigroup<Kind3<F, R, E, A>>
export declare function getApplySemigroup<F extends URIS3, E>(
  F: Apply3C<F, E>
): <A, R>(S: Semigroup<A>) => Semigroup<Kind3<F, R, E, A>>
export declare function getApplySemigroup<F extends URIS2>(
  F: Apply2<F>
): <A, E>(S: Semigroup<A>) => Semigroup<Kind2<F, E, A>>
export declare function getApplySemigroup<F extends URIS2, E>(
  F: Apply2C<F, E>
): <A>(S: Semigroup<A>) => Semigroup<Kind2<F, E, A>>
export declare function getApplySemigroup<F extends URIS>(F: Apply1<F>): <A>(S: Semigroup<A>) => Semigroup<Kind<F, A>>
export declare function getApplySemigroup<F>(F: Apply<F>): <A>(S: Semigroup<A>) => Semigroup<HKT<F, A>>

Added in v2.10.0 v2.10.0 中添加

sequenceS   序列S

Like Apply.sequenceT but works with structs instead of tuples.
Apply.sequenceT 类似,但适用于结构而不是元组。

Signature 签名

export declare function sequenceS<F extends URIS4>(
  F: Apply4<F>
): <S, R, E, NER extends Record<string, Kind4<F, S, R, E, any>>>(
  r: EnforceNonEmptyRecord<NER> & Record<string, Kind4<F, S, R, E, any>>
) => Kind4<F, S, R, E, { [K in keyof NER]: [NER[K]] extends [Kind4<F, any, any, any, infer A>] ? A : never }>
export declare function sequenceS<F extends URIS3>(
  F: Apply3<F>
): <R, E, NER extends Record<string, Kind3<F, R, E, any>>>(
  r: EnforceNonEmptyRecord<NER> & Record<string, Kind3<F, R, E, any>>
) => Kind3<F, R, E, { [K in keyof NER]: [NER[K]] extends [Kind3<F, any, any, infer A>] ? A : never }>
export declare function sequenceS<F extends URIS3, E>(
  F: Apply3C<F, E>
): <R, NER extends Record<string, Kind3<F, R, E, any>>>(
  r: EnforceNonEmptyRecord<NER> & Record<string, Kind3<F, R, E, any>>
) => Kind3<F, R, E, { [K in keyof NER]: [NER[K]] extends [Kind3<F, any, any, infer A>] ? A : never }>
export declare function sequenceS<F extends URIS2>(
  F: Apply2<F>
): <E, NER extends Record<string, Kind2<F, E, any>>>(
  r: EnforceNonEmptyRecord<NER> & Record<string, Kind2<F, E, any>>
) => Kind2<F, E, { [K in keyof NER]: [NER[K]] extends [Kind2<F, any, infer A>] ? A : never }>
export declare function sequenceS<F extends URIS2, E>(
  F: Apply2C<F, E>
): <NER extends Record<string, Kind2<F, E, any>>>(
  r: EnforceNonEmptyRecord<NER>
) => Kind2<F, E, { [K in keyof NER]: [NER[K]] extends [Kind2<F, any, infer A>] ? A : never }>
export declare function sequenceS<F extends URIS>(
  F: Apply1<F>
): <NER extends Record<string, Kind<F, any>>>(
  r: EnforceNonEmptyRecord<NER>
) => Kind<F, { [K in keyof NER]: [NER[K]] extends [Kind<F, infer A>] ? A : never }>
export declare function sequenceS<F>(
  F: Apply<F>
): <NER extends Record<string, HKT<F, any>>>(
  r: EnforceNonEmptyRecord<NER>
) => HKT<F, { [K in keyof NER]: [NER[K]] extends [HKT<F, infer A>] ? A : never }>

Example 例子

import * as E from 'fp-ts/Either'
import { sequenceS } from 'fp-ts/Apply'

const ado = sequenceS(E.Apply)

assert.deepStrictEqual(
  ado({
    a: E.right(1),
    b: E.right(true),
  }),
  E.right({ a: 1, b: true })
)
assert.deepStrictEqual(
  ado({
    a: E.right(1),
    b: E.left('error'),
  }),
  E.left('error')
)

Added in v2.0.0 v2.0.0 中添加

sequenceT   序列T

Tuple sequencing, i.e., take a tuple of monadic actions and does them from left-to-right, returning the resulting tuple.
元组排序,即采用一元操作的元组并从左到右执行它们,返回结果元组。

Signature 签名

export declare function sequenceT<F extends URIS4>(
  F: Apply4<F>
): <S, R, E, T extends Array<Kind4<F, S, R, E, any>>>(
  ...t: T & { readonly 0: Kind4<F, S, R, E, any> }
) => Kind4<F, S, R, E, { [K in keyof T]: [T[K]] extends [Kind4<F, S, R, E, infer A>] ? A : never }>
export declare function sequenceT<F extends URIS3>(
  F: Apply3<F>
): <R, E, T extends Array<Kind3<F, R, E, any>>>(
  ...t: T & { readonly 0: Kind3<F, R, E, any> }
) => Kind3<F, R, E, { [K in keyof T]: [T[K]] extends [Kind3<F, R, E, infer A>] ? A : never }>
export declare function sequenceT<F extends URIS3, E>(
  F: Apply3C<F, E>
): <R, T extends Array<Kind3<F, R, E, any>>>(
  ...t: T & { readonly 0: Kind3<F, R, E, any> }
) => Kind3<F, R, E, { [K in keyof T]: [T[K]] extends [Kind3<F, R, E, infer A>] ? A : never }>
export declare function sequenceT<F extends URIS2>(
  F: Apply2<F>
): <E, T extends Array<Kind2<F, E, any>>>(
  ...t: T & { readonly 0: Kind2<F, E, any> }
) => Kind2<F, E, { [K in keyof T]: [T[K]] extends [Kind2<F, E, infer A>] ? A : never }>
export declare function sequenceT<F extends URIS2, E>(
  F: Apply2C<F, E>
): <T extends Array<Kind2<F, E, any>>>(
  ...t: T & { readonly 0: Kind2<F, E, any> }
) => Kind2<F, E, { [K in keyof T]: [T[K]] extends [Kind2<F, E, infer A>] ? A : never }>
export declare function sequenceT<F extends URIS>(
  F: Apply1<F>
): <T extends Array<Kind<F, any>>>(
  ...t: T & { readonly 0: Kind<F, any> }
) => Kind<F, { [K in keyof T]: [T[K]] extends [Kind<F, infer A>] ? A : never }>
export declare function sequenceT<F>(
  F: Apply<F>
): <T extends Array<HKT<F, any>>>(
  ...t: T & { readonly 0: HKT<F, any> }
) => HKT<F, { [K in keyof T]: [T[K]] extends [HKT<F, infer A>] ? A : never }>

Example 例子

import { sequenceT } from 'fp-ts/Apply'
import * as O from 'fp-ts/Option'

const sequenceTOption = sequenceT(O.Apply)
assert.deepStrictEqual(sequenceTOption(O.some(1)), O.some([1]))
assert.deepStrictEqual(sequenceTOption(O.some(1), O.some('2')), O.some([1, '2']))
assert.deepStrictEqual(sequenceTOption(O.some(1), O.some('2'), O.none), O.none)

Added in v2.0.0 v2.0.0 中添加

Array overview  阵列概览

The Array module provides tools for working with Typescript’s Array type in a functional way.
Array 模块提供了以函数方式处理 Typescript 的 Array 类型的工具。

In functional jargon, this module provides a monadic interface over Typescript’s Array
用功能术语来说,该模块通过 Typescript 的 Array 提供了一个单子接口
.

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


constructors  构造函数

makeBy  制造者

Return a Array of length n with element i initialized with f(i).
返回长度为 nArray ,其中元素 if(i) 初始化。

Note. n is normalized to a non negative integer.
笔记。 n 被标准化为非负整数。

Signature 签名

export declare const makeBy: <A>(n: number, f: (i: number) => A) => A[]

Example 例子

import { makeBy } from 'fp-ts/Array'

const double = (i: number): number => i * 2
assert.deepStrictEqual(makeBy(5, double), [0, 2, 4, 6, 8])
assert.deepStrictEqual(makeBy(-3, double), [])
assert.deepStrictEqual(makeBy(4.32164, double), [0, 2, 4, 6])

Added in v2.0.0 v2.0.0 中添加

of  

Given an element of the base type, of builds an Array containing just that element of the base type (this is useful for building a Monad).
给定一个基本类型的元素, of 构建一个仅包含该基本类型元素的 Array (这对于构建 Monad 很有用)。

Signature 签名

export declare const of: <A>(a: A) => A[]

Example 例子

import { of } from 'fp-ts/Array'

assert.deepStrictEqual(of('a'), ['a'])

Added in v2.0.0 v2.0.0 中添加

replicate   复制

Create a Array containing a value repeated the specified number of times.
创建一个包含重复指定次数的值的 Array

Note. n is normalized to a non negative integer.
笔记。 n 被标准化为非负整数。

Signature 签名

export declare const replicate: <A>(n: number, a: A) => A[]

Example 例子

import { replicate } from 'fp-ts/Array'

assert.deepStrictEqual(replicate(3, 'a'), ['a', 'a', 'a'])
assert.deepStrictEqual(replicate(-3, 'a'), [])
assert.deepStrictEqual(replicate(2.985647, 'a'), ['a', 'a'])

Added in v2.0.0 v2.0.0 中添加

conversions   转换

fromEither   来自任一

Create an array from an Either. The resulting array will contain the content of the Either if it is Right and it will be empty if the Either is Left.
Either 创建一个数组。如果 Right 则结果数组将包含 Either 的内容,如果 EitherLeft 则结果数组将为空。

Signature 签名

export declare const fromEither: <A>(fa: Either<unknown, A>) => A[]

Example 例子

import { fromEither } from 'fp-ts/Array'
import { either } from 'fp-ts'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe(either.right('r'), fromEither), ['r'])
assert.deepStrictEqual(pipe(either.left('l'), fromEither), [])

Added in v2.11.0 v2.11.0 中添加

fromOption   来自选项

Create an array from an Option. The resulting array will contain the content of the Option if it is Some and it will be empty if the Option is None.
Option 创建一个数组。如果 Some 则结果数组将包含 Option 的内容,如果 OptionNone 则结果数组将为空。

Signature 签名

export declare const fromOption: <A>(fa: Option<A>) => A[]

Example 例子

import { fromOption } from 'fp-ts/Array'
import { option } from 'fp-ts'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe(option.some('a'), fromOption), ['a'])
assert.deepStrictEqual(pipe(option.none, fromOption), [])

Added in v2.11.0 v2.11.0 中添加

do notation   做记号

Do  

Signature 签名

export declare const Do: {}[]

Added in v2.9.0 v2.9.0中添加

apS   apS

Signature 签名

export declare const apS: <N, A, B>(
  name: Exclude<N, keyof A>,
  fb: B[]
) => (fa: A[]) => { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }[]

Added in v2.8.0 v2.8.0 中添加

bind   绑定

Signature 签名

export declare const bind: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B[]
) => (ma: A[]) => { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }[]

Added in v2.8.0 v2.8.0 中添加

bindTo   绑定到

Signature 签名

export declare const bindTo: <N>(name: N) => <A>(fa: A[]) => { readonly [K in N]: A }[]

Added in v2.8.0 v2.8.0 中添加

guard   警卫

Signature 签名

export declare const guard: (b: boolean) => void[]

Added in v2.11.0 v2.11.0 中添加

let  

Signature 签名

export declare const let: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => (fa: A[]) => { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }[]

Added in v2.13.0 v2.13.0 中添加

error handling   错误处理

alt   替代

Identifies an associative operation on a type constructor. It is similar to Semigroup, except that it applies to types of kind * -> *.
标识类型构造函数上的关联操作。它与 Semigroup 类似,但它适用于 * -> * 类型。

In case of Array concatenates the inputs into a single array.
如果是 Array ,则将输入连接到单个数组中。

Signature 签名

export declare const alt: <A>(that: LazyArg<A[]>) => (fa: A[]) => A[]

Example 例子

import * as A from 'fp-ts/Array'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(
  pipe(
    [1, 2, 3],
    A.alt(() => [4, 5])
  ),
  [1, 2, 3, 4, 5]
)

Added in v2.0.0 v2.0.0 中添加

altW   替代W

Less strict version of alt.
alt 的不太严格版本。

The W suffix (short for Widening) means that the return types will be merged.
W 后缀(Widening 的缩写)意味着返回类型将被合并。

Signature 签名

export declare const altW: <B>(that: LazyArg<B[]>) => <A>(fa: A[]) => (B | A)[]

Example 例子

import * as A from 'fp-ts/Array'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(
  pipe(
    [1, 2, 3],
    A.altW(() => ['a', 'b'])
  ),
  [1, 2, 3, 'a', 'b']
)

Added in v2.9.0 v2.9.0中添加

filtering   过滤

compact   袖珍的

Compact an array of Options discarding the None values and keeping the Some values. It returns a new array containing the values of the Some options.
压缩 Option 数组,丢弃 None 值并保留 Some 值。它返回一个包含 Some 选项值的新数组。

Signature 签名

export declare const compact: <A>(fa: Option<A>[]) => A[]

Example 例子

import { compact } from 'fp-ts/Array'
import { option } from 'fp-ts'

assert.deepStrictEqual(compact([option.some('a'), option.none, option.some('b')]), ['a', 'b'])

Added in v2.0.0 v2.0.0 中添加

filter   筛选

Given an iterating function that is a Predicate or a Refinement, filter creates a new Array containing the elements of the original Array for which the iterating function is true.
给定一个迭代函数 PredicateRefinementfilter 创建一个新的 Array ,其中包含原始 Array 的元素,而迭代函数为 true

Signature 签名

export declare const filter: {
  <A, B extends A>(refinement: Refinement<A, B>): (as: A[]) => B[]
  <A>(predicate: Predicate<A>): <B extends A>(bs: B[]) => B[]
  <A>(predicate: Predicate<A>): (as: A[]) => A[]
}

Example 例子

import { filter } from 'fp-ts/Array'
import { isString } from 'fp-ts/lib/string'

assert.deepStrictEqual(filter(isString)(['a', 1, {}, 'b', 5]), ['a', 'b'])
assert.deepStrictEqual(filter((x: number) => x > 0)([-3, 1, -2, 5]), [1, 5])

Added in v2.0.0 v2.0.0 中添加

filterMap   过滤映射

Maps an array with an iterating function that returns an Option and it keeps only the Some values discarding the Nones.
使用返回 Option 的迭代函数映射数组,并且仅保留 Some 值并丢弃 None

Signature 签名

export declare const filterMap: <A, B>(f: (a: A) => Option<B>) => (fa: A[]) => B[]

Example 例子

import { filterMap } from 'fp-ts/Array'
import { pipe } from 'fp-ts/function'
import { option } from 'fp-ts'

const f = (s: string) => (s.length === 1 ? option.some(s.toUpperCase()) : option.none)
assert.deepStrictEqual(pipe(['a', 'no', 'neither', 'b'], filterMap(f)), ['A', 'B'])

Added in v2.0.0 v2.0.0 中添加

filterMapWithIndex   带索引的过滤映射

Maps an array with an iterating function that takes the index and the value of each element and returns an Option. It keeps only the Some values discarding the Nones.
使用迭代函数映射数组,该迭代函数获取每个元素的索引和值并返回 Option 。它仅保留 Some 值,丢弃 None 值。

Same as filterMap, but with an iterating function which takes also the index as input.
filterMap 相同,但具有迭代函数,该函数也将索引作为输入。

Signature 签名

export declare const filterMapWithIndex: <A, B>(f: (i: number, a: A) => Option<B>) => (fa: A[]) => B[]

Example 例子

import { filterMapWithIndex } from 'fp-ts/Array'
import { pipe } from 'fp-ts/function'
import { option } from 'fp-ts'

const f = (i: number, s: string) => (i % 2 === 1 ? option.some(s.toUpperCase()) : option.none)
assert.deepStrictEqual(pipe(['a', 'no', 'neither', 'b'], filterMapWithIndex(f)), ['NO', 'B'])

Added in v2.0.0 v2.0.0 中添加

filterWithIndex   带索引的过滤器

Same as filter, but passing also the index to the iterating function.
filter 相同,但还将索引传递给迭代函数。

Signature 签名

export declare const filterWithIndex: {
  <A, B extends A>(refinementWithIndex: RefinementWithIndex<number, A, B>): (as: A[]) => B[]
  <A>(predicateWithIndex: PredicateWithIndex<number, A>): <B extends A>(bs: B[]) => B[]
  <A>(predicateWithIndex: PredicateWithIndex<number, A>): (as: A[]) => A[]
}

Example 例子

import { filterWithIndex } from 'fp-ts/Array'

const f = (index: number, x: number) => x > 0 && index <= 2
assert.deepStrictEqual(filterWithIndex(f)([-3, 1, -2, 5]), [1])

Added in v2.0.0 v2.0.0 中添加

partition   分割

Given an iterating function that is a Predicate or a Refinement, partition creates two new Arrays: right containing the elements of the original Array for which the iterating function is true, left containing the elements for which it is false.
给定一个迭代函数 PredicateRefinementpartition 创建两个新的 Arrayright 包含原始 Array 的元素,而迭代函数为 true 、@ 7# 包含为 false 的元素。

Signature 签名

export declare const partition: {
  <A, B extends A>(refinement: Refinement<A, B>): (as: A[]) => Separated<A[], B[]>
  <A>(predicate: Predicate<A>): <B extends A>(bs: B[]) => Separated<B[], B[]>
  <A>(predicate: Predicate<A>): (as: A[]) => Separated<A[], A[]>
}

Example 例子

import { partition } from 'fp-ts/Array'
import { isString } from 'fp-ts/lib/string'

assert.deepStrictEqual(partition(isString)(['a', 1, {}, 'b', 5]), { left: [1, {}, 5], right: ['a', 'b'] })
assert.deepStrictEqual(partition((x: number) => x > 0)([-3, 1, -2, 5]), { left: [-3, -2], right: [1, 5] })

Added in v2.0.0 v2.0.0 中添加

partitionMap   分区图

Given an iterating function that returns an Either, partitionMap applies the iterating function to each element and it creates two Arrays: right containing the values of Right results, left containing the values of Left results.
给定一个返回 Either 的迭代函数, partitionMap 将迭代函数应用于每个元素,并创建两个 Arrayright 包含 Right 结果的值, left 包含 @ 的值6# 结果。

Signature 签名

export declare const partitionMap: <A, B, C>(f: (a: A) => Either<B, C>) => (fa: A[]) => Separated<B[], C[]>

Example 例子

import { partitionMap } from 'fp-ts/Array'
import { Either, left, right } from 'fp-ts/lib/Either'

const upperIfString = <B>(x: B): Either<B, string> => (typeof x === 'string' ? right(x.toUpperCase()) : left(x))
assert.deepStrictEqual(partitionMap(upperIfString)([-2, 'hello', 6, 7, 'world']), {
  left: [-2, 6, 7],
  right: ['HELLO', 'WORLD'],
})

Added in v2.0.0 v2.0.0 中添加

partitionMapWithIndex   带索引的分区映射

Same as partitionMap, but passing also the index to the iterating function.
partitionMap 相同,但还将索引传递给迭代函数。

Signature 签名

export declare const partitionMapWithIndex: <A, B, C>(
  f: (i: number, a: A) => Either<B, C>
) => (fa: A[]) => Separated<B[], C[]>

Example 例子

import { partitionMapWithIndex } from 'fp-ts/Array'
import { Either, left, right } from 'fp-ts/lib/Either'

const upperIfStringBefore3 = <B>(index: number, x: B): Either<B, string> =>
  index < 3 && typeof x === 'string' ? right(x.toUpperCase()) : left(x)
assert.deepStrictEqual(partitionMapWithIndex(upperIfStringBefore3)([-2, 'hello', 6, 7, 'world']), {
  left: [-2, 6, 7, 'world'],
  right: ['HELLO'],
})

Added in v2.0.0 v2.0.0 中添加

partitionWithIndex   带索引分区

Same as partition, but passing also the index to the iterating function.
partition 相同,但还将索引传递给迭代函数。

Signature 签名

export declare const partitionWithIndex: {
  <A, B extends A>(refinementWithIndex: RefinementWithIndex<number, A, B>): (as: A[]) => Separated<A[], B[]>
  <A>(predicateWithIndex: PredicateWithIndex<number, A>): <B extends A>(bs: B[]) => Separated<B[], B[]>
  <A>(predicateWithIndex: PredicateWithIndex<number, A>): (as: A[]) => Separated<A[], A[]>
}

Example 例子

import { partitionWithIndex } from 'fp-ts/Array'

assert.deepStrictEqual(partitionWithIndex((index, x: number) => index < 3 && x > 0)([-2, 5, 6, 7]), {
  left: [-2, 7],
  right: [5, 6],
})

Added in v2.0.0 v2.0.0 中添加

separate   分离

Separate an array of Eithers into Lefts and Rights, creating two new arrays: one containing all the left values and one containing all the right values.
Either 数组分成 LeftRight ,创建两个新数组:一个包含所有左侧值,另一个包含所有右侧值。

Signature 签名

export declare const separate: <A, B>(fa: Either<A, B>[]) => Separated<A[], B[]>

Example 例子

import { separate } from 'fp-ts/Array'
import { either } from 'fp-ts'

assert.deepStrictEqual(separate([either.right('r1'), either.left('l1'), either.right('r2')]), {
  left: ['l1'],
  right: ['r1', 'r2'],
})

Added in v2.0.0 v2.0.0 中添加

wilt   枯萎

Signature 签名

export declare const wilt: PipeableWilt1<'Array'>

Added in v2.6.5 v2.6.5 中添加

wither   枯萎

Signature 签名

export declare const wither: PipeableWither1<'Array'>

Added in v2.6.5 v2.6.5 中添加

folding   折叠式的

foldMap   折叠图

Map and fold an Array. Map the Array passing each value to the iterating function. Then fold the results using the provided Monoid.
映射并折叠 Array 。映射 Array 将每个值传递给迭代函数。然后使用提供的 Monoid 折叠结果。

Signature 签名

export declare const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: A[]) => M

Example 例子

import { foldMap } from 'fp-ts/Array'

const monoid = { concat: (a: string, b: string) => a + b, empty: '' }
const f = (s: string) => s.toUpperCase()
assert.deepStrictEqual(foldMap(monoid)(f)(['a', 'b', 'c']), 'ABC')

Added in v2.0.0 v2.0.0 中添加

foldMapWithIndex   带索引的折叠地图

Same as foldMap but passing also the index to the iterating function.
foldMap 相同,但还将索引传递给迭代函数。

Signature 签名

export declare const foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: number, a: A) => M) => (fa: A[]) => M

Example 例子

import { foldMapWithIndex } from 'fp-ts/Array'

const monoid = { concat: (a: string, b: string) => a + b, empty: '' }
const f = (index: number, s: string) => `${s.toUpperCase()}(${index})`
assert.deepStrictEqual(foldMapWithIndex(monoid)(f)(['a', 'b', 'c']), 'A(0)B(1)C(2)')

Added in v2.0.0 v2.0.0 中添加

reduce   减少

Reduces an Array. 减少 Array

reduce executes the supplied iterating function on each element of the array, in order, passing in the element and the return value from the calculation on the preceding element.
reduce 按顺序对数组的每个元素执行提供的迭代函数,并传入该元素和前一个元素计算的返回值。

The first time that the iterating function is called there is no “return value of the previous calculation”, the initial value is used in its place.
第一次调用迭代函数时,没有“上次计算的返回值”,而是使用初始值。

Signature 签名

export declare const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: A[]) => B

Example 例子

import { reduce } from 'fp-ts/Array'

assert.deepStrictEqual(reduce(5, (acc: number, cur: number) => acc * cur)([2, 3]), 5 * 2 * 3)

Added in v2.0.0 v2.0.0 中添加

reduceRight   减少右

Same as reduce but applied from the end to the start.
reduce 相同,但从末尾应用到开头。

Note: the iterating function in this case takes the accumulator as the last argument.
注意:本例中的迭代函数将累加器作为最后一个参数。

Signature 签名

export declare const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: A[]) => B

Example 例子

import { reduceRight } from 'fp-ts/Array'

assert.deepStrictEqual(reduceRight('', (cur: string, acc: string) => acc + cur)(['a', 'b', 'c']), 'cba')

Added in v2.0.0 v2.0.0 中添加

reduceRightWithIndex   减少右索引

Same as reduceRight but passing also the index to the iterating function.
reduceRight 相同,但还将索引传递给迭代函数。

Signature 签名

export declare const reduceRightWithIndex: <A, B>(b: B, f: (i: number, a: A, b: B) => B) => (fa: A[]) => B

Example 例子

import { reduceRightWithIndex } from 'fp-ts/Array'

const f = (index: number, cur: unknown, acc: string) => acc + (typeof cur === 'string' ? cur.toUpperCase() + index : '')
assert.deepStrictEqual(reduceRightWithIndex('', f)([2, 'a', 'b', null]), 'B2A1')

Added in v2.0.0 v2.0.0 中添加

reduceWithIndex  减少索引

Same as reduce but passing also the index to the iterating function.
reduce 相同,但还将索引传递给迭代函数。

Signature 签名

export declare const reduceWithIndex: <A, B>(b: B, f: (i: number, b: B, a: A) => B) => (fa: A[]) => B

Example 例子

import { reduceWithIndex } from 'fp-ts/Array'

const f = (index: number, acc: string, cur: unknown) => acc + (typeof cur === 'string' ? cur.toUpperCase() + index : '')
assert.deepStrictEqual(reduceWithIndex('', f)([2, 'a', 'b', null]), 'A1B2')

Added in v2.0.0 v2.0.0 中添加

instances   实例

Alt   替代

Signature 签名

export declare const Alt: Alt1<'Array'>

Added in v2.7.0 v2.7.0 中添加

Alternative   选择

Signature 签名

export declare const Alternative: Alternative1<'Array'>

Added in v2.7.0 v2.7.0 中添加

Applicative   适用性

Signature 签名

export declare const Applicative: Applicative1<'Array'>

Added in v2.7.0 v2.7.0 中添加

Apply   申请

Signature 签名

export declare const Apply: Apply1<'Array'>

Added in v2.10.0 v2.10.0 中添加

Chain  

Signature 签名

export declare const Chain: Chain1<'Array'>

Added in v2.10.0 v2.10.0 中添加

ChainRecBreadthFirst   链式记录宽度优先

Signature 签名

export declare const ChainRecBreadthFirst: ChainRec1<'Array'>

Added in v2.11.0 v2.11.0 中添加

ChainRecDepthFirst   链式记录深度优先

Signature 签名

export declare const ChainRecDepthFirst: ChainRec1<'Array'>

Added in v2.11.0 v2.11.0 中添加

Compactable   紧凑型

Signature 签名

export declare const Compactable: Compactable1<'Array'>

Added in v2.7.0 v2.7.0 中添加

Extend   延长

Signature 签名

export declare const Extend: Extend1<'Array'>

Added in v2.7.0 v2.7.0 中添加

Filterable   可过滤

Signature 签名

export declare const Filterable: Filterable1<'Array'>

Added in v2.7.0 v2.7.0 中添加

FilterableWithIndex   可通过索引过滤

Signature 签名

export declare const FilterableWithIndex: FilterableWithIndex1<'Array', number>

Added in v2.7.0 v2.7.0 中添加

Foldable   折叠式

Signature 签名

export declare const Foldable: Foldable1<'Array'>

Added in v2.7.0 v2.7.0 中添加

FoldableWithIndex   可折叠带索引

Signature 签名

export declare const FoldableWithIndex: FoldableWithIndex1<'Array', number>

Added in v2.7.0 v2.7.0 中添加

FromEither   来自任一

Signature 签名

export declare const FromEither: FromEither1<'Array'>

Added in v2.11.0 v2.11.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor1<'Array'>

Added in v2.7.0 v2.7.0 中添加

FunctorWithIndex   带索引的函子

Signature 签名

export declare const FunctorWithIndex: FunctorWithIndex1<'Array', number>

Added in v2.7.0 v2.7.0 中添加

Monad   单子

Signature 签名

export declare const Monad: Monad1<'Array'>

Added in v2.7.0 v2.7.0 中添加

Pointed  

Signature 签名

export declare const Pointed: Pointed1<'Array'>

Added in v2.10.0 v2.10.0 中添加

Traversable   可穿越

Signature 签名

export declare const Traversable: Traversable1<'Array'>

Added in v2.7.0 v2.7.0 中添加

TraversableWithIndex   可遍历索引

Signature 签名

export declare const TraversableWithIndex: TraversableWithIndex1<'Array', number>

Added in v2.7.0 v2.7.0 中添加

Unfoldable   可折叠

Signature 签名

export declare const Unfoldable: Unfoldable1<'Array'>

Added in v2.7.0 v2.7.0 中添加

Witherable   枯萎的

Signature 签名

export declare const Witherable: Witherable1<'Array'>

Added in v2.7.0 v2.7.0 中添加

Zero  

Signature 签名

export declare const Zero: Zero1<'Array'>

Added in v2.11.0 v2.11.0 中添加

getDifferenceMagma   获取差异岩浆

Get a Magma for Array where the concat function is the differnce between the first and the second array, i.e. the result contains all the elements of the first array for which their is no equal element in the second array according to the Eq provided.
Array 获取 Magma ,其中 concat 函数是第一个数组和第二个数组之间的差异,即结果包含第一个数组的所有元素,而它们在第二个数组中的元素不相等,根据提供的 Eq

Signature 签名

export declare const getDifferenceMagma: <A>(E: Eq<A>) => Magma<A[]>

Example 例子

import { getDifferenceMagma } from 'fp-ts/Array'
import { Eq } from 'fp-ts/number'

const S = getDifferenceMagma<number>(Eq)
assert.deepStrictEqual(S.concat([1, 2], [2, 3]), [1])

Added in v2.11.0 v2.11.0 中添加

getEq   得到方程

Derives an Eq over the Array of a given element type from the Eq of that type. The derived Eq defines two arrays as equal if all elements of both arrays are compared equal pairwise with the given E. In case of arrays of different lengths, the result is non equality.
从给定元素类型的 Eq 派生出 Eq ,而不是该类型的 Array 。如果两个数组的所有元素与给定的 E 成对比较,则派生的 Eq 将两个数组定义为相等。如果数组长度不同,结果不相等。

Signature 签名

export declare const getEq: <A>(E: Eq<A>) => Eq<A[]>

Example 例子

import * as S from 'fp-ts/string'
import { getEq } from 'fp-ts/Array'

const E = getEq(S.Eq)
assert.strictEqual(E.equals(['a', 'b'], ['a', 'b']), true)
assert.strictEqual(E.equals(['a'], []), false)

Added in v2.0.0 v2.0.0 中添加

getIntersectionSemigroup
获取交集半群

Get a Semigroup based on the intersection of the elements of Arrays. Only elements present in the two arrays which are equal according to the provided Eq are included in the result.
根据 Array s 的元素的交集得到 Semigroup 。结果中仅包含根据提供的 Eq 相等的两个数组中存在的元素。

Signature 签名

export declare const getIntersectionSemigroup: <A>(E: Eq<A>) => Semigroup<A[]>

Example 例子

import { getIntersectionSemigroup } from 'fp-ts/Array'
import { Eq } from 'fp-ts/number'

const S = getIntersectionSemigroup<number>(Eq)
assert.deepStrictEqual(S.concat([1, 2], [2, 3]), [2])

Added in v2.11.0 v2.11.0 中添加

getMonoid   获取Monoid

Returns a Monoid for Array<A> based on the concatenation of Arrays.
根据 Array 的串联,为 Array<A> 返回 Monoid

Signature 签名

export declare const getMonoid: <A = never>() => Monoid<A[]>

Example 例子

import { getMonoid } from 'fp-ts/Array'

const M = getMonoid<number>()
assert.deepStrictEqual(M.concat([1, 2], [3, 4]), [1, 2, 3, 4])

Added in v2.0.0 v2.0.0 中添加

getOrd   获取订单

Derives an Ord over the Array of a given element type from the Ord of that type. The ordering between two such arrays is equal to: the first non equal comparison of each arrays elements taken pairwise in increasing order, in case of equality over all the pairwise elements; the longest array is considered the greatest, if both arrays have the same length, the result is equality.
从给定元素类型的 Ord 派生出 Ord ,而不是该类型的 Array 。两个这样的数组之间的顺序等于:如果所有成对元素相等,则按升序对每个数组元素进行第一个不相等比较;最长的数组被认为是最大的,如果两个数组的长度相同,则结果相等。

Signature 签名

export declare const getOrd: <A>(O: Ord<A>) => Ord<A[]>

Example 例子

import { getOrd } from 'fp-ts/Array'
import * as S from 'fp-ts/string'

const O = getOrd(S.Ord)
assert.strictEqual(O.compare(['b'], ['a']), 1)
assert.strictEqual(O.compare(['a'], ['a']), 0)
assert.strictEqual(O.compare(['a'], ['b']), -1)

Added in v2.0.0 v2.0.0 中添加

getSemigroup   获取半群

Get a Semigroup based on the concatenation of Arrays. See also getMonoid.
根据 Array 的串联得到 Semigroup 。另请参阅 getMonoid

Signature 签名

export declare const getSemigroup: <A = never>() => Semigroup<A[]>

Example 例子

import { getSemigroup } from 'fp-ts/Array'

const S = getSemigroup<number>()
assert.deepStrictEqual(S.concat([1, 2], [2, 3]), [1, 2, 2, 3])

Added in v2.10.0 v2.10.0 中添加

getShow   获取显示

getShow makes a Show for an Array<A> from a Show for an A.
getShowShow 变为 A ,将 Show 变为 Array<A>

Signature 签名

export declare const getShow: <A>(S: Show<A>) => Show<A[]>

Example 例子

import { getShow } from 'fp-ts/Array'

const numShow = { show: (n: number) => (n >= 0 ? `${n}` : `(${-n})`) }
assert.deepStrictEqual(getShow(numShow).show([-2, -1, 0, 1]), '[(2), (1), 0, 1]')

Added in v2.0.0 v2.0.0 中添加

getUnionMonoid  获取UnionMonoid

Get a Monoid based on the union of the elements of Arrays. Elements which equal according to the provided Eq are included only once in the result.
根据 Array s 的元素并集得到 Monoid 。根据提供的 Eq 相等的元素仅在结果中包含一次。

Signature 签名

export declare const getUnionMonoid: <A>(E: Eq<A>) => Monoid<A[]>

Example 例子

import { getUnionMonoid } from 'fp-ts/Array'
import { Eq } from 'fp-ts/number'

const M = getUnionMonoid<number>(Eq)
assert.deepStrictEqual(M.concat([1, 2], [2, 3]), [1, 2, 3])
assert.deepStrictEqual(M.empty, [])

Added in v2.11.0 v2.11.0 中添加

getUnionSemigroup   获取UnionSemigroup

Get a Semigroup based on the union of the elements of Arrays. Elements which equal according to the provided Eq are included only once in the result. See also getUnionMonoid.
根据 Array s 的元素并集得到 Semigroup 。根据提供的 Eq 相等的元素仅在结果中包含一次。另请参阅 getUnionMonoid

Signature 签名

export declare const getUnionSemigroup: <A>(E: Eq<A>) => Semigroup<A[]>

Example 例子

import { getUnionSemigroup } from 'fp-ts/Array'
import { Eq } from 'fp-ts/number'

const S = getUnionSemigroup<number>(Eq)
assert.deepStrictEqual(S.concat([1, 2], [2, 3]), [1, 2, 3])

Added in v2.11.0 v2.11.0 中添加

legacy   遗产

chain  

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chain: <A, B>(f: (a: A) => B[]) => (ma: A[]) => B[]

Added in v2.0.0 v2.0.0 中添加

lifting   起重

fromEitherK   来自EitherK

Signature 签名

export declare const fromEitherK: <E, A extends readonly unknown[], B>(f: (...a: A) => Either<E, B>) => (...a: A) => B[]

Added in v2.11.0 v2.11.0 中添加

fromOptionK   来自选项K

Signature 签名

export declare const fromOptionK: <A extends readonly unknown[], B>(f: (...a: A) => Option<B>) => (...a: A) => B[]

Added in v2.11.0 v2.11.0 中添加

fromPredicate   来自谓词

Create an array with one element, if the element satisfies the predicate, otherwise it returns an empty array.
创建一个包含一个元素的数组,如果该元素满足谓词,否则返回一个空数组。

Signature 签名

export declare function fromPredicate<A, B extends A>(refinement: Refinement<A, B>): (a: A) => Array<B>
export declare function fromPredicate<A>(predicate: Predicate<A>): <B extends A>(b: B) => Array<B>
export declare function fromPredicate<A>(predicate: Predicate<A>): (a: A) => Array<A>

Example 例子

import { fromPredicate } from 'fp-ts/Array'
import { pipe } from 'fp-ts/function'
import { isString } from 'fp-ts/lib/string'

assert.deepStrictEqual(pipe('a', fromPredicate(isString)), ['a'])
assert.deepStrictEqual(pipe(7, fromPredicate(isString)), [])

assert.deepStrictEqual(
  pipe(
    7,
    fromPredicate((x) => x > 0)
  ),
  [7]
)
assert.deepStrictEqual(
  pipe(
    -3,
    fromPredicate((x) => x > 0)
  ),
  []
)

Added in v2.11.0 v2.11.0 中添加

mapping   映射

flap   皮瓣

Given an input an Array of functions, flap returns an Array containing the results of applying each function to the given input.
给定一个输入 Array 函数, flap 返回一个 Array ,其中包含将每个函数应用于给定输入的结果。

Signature 签名

export declare const flap: <A>(a: A) => <B>(fab: ((a: A) => B)[]) => B[]

Example 例子

import { flap } from 'fp-ts/Array'

const funs = [(n: number) => `Double: ${n * 2}`, (n: number) => `Triple: ${n * 3}`, (n: number) => `Square: ${n * n}`]
assert.deepStrictEqual(flap(4)(funs), ['Double: 8', 'Triple: 12', 'Square: 16'])

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: Array<A>) => Array<B>. In practice it applies the base function to each element of the array and collects the results in a new array.
map 可用于将函数 (a: A) => B 转换为函数 (fa: Array<A>) => Array<B> 。实际上,它将基函数应用于数组的每个元素,并将结果收集到一个新数组中。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => (fa: A[]) => B[]

Example 例子

import { map } from 'fp-ts/Array'
import { pipe } from 'fp-ts/function'

const f = (n: number) => n * 2
assert.deepStrictEqual(pipe([1, 2, 3], map(f)), [2, 4, 6])

Added in v2.0.0 v2.0.0 中添加

mapWithIndex   带索引的映射

Same as map, but the iterating function takes both the index and the value of the element.
map 相同,但迭代函数同时获取元素的索引和值。

Signature 签名

export declare const mapWithIndex: <A, B>(f: (i: number, a: A) => B) => (fa: A[]) => B[]

Example 例子

import { mapWithIndex } from 'fp-ts/Array'
import { pipe } from 'fp-ts/function'

const f = (i: number, s: string) => `${s} - ${i}`
assert.deepStrictEqual(pipe(['a', 'b', 'c'], mapWithIndex(f)), ['a - 0', 'b - 1', 'c - 2'])

Added in v2.0.0 v2.0.0 中添加

pattern matching   模式匹配

foldLeft   向左折叠

Alias of matchLeft.  matchLeft 的别名。

Signature 签名

export declare const foldLeft: <A, B>(onEmpty: LazyArg<B>, onNonEmpty: (head: A, tail: A[]) => B) => (as: A[]) => B

Added in v2.0.0 v2.0.0 中添加

foldRight   向右折叠

Alias of matchRight.  matchRight 的别名。

Signature 签名

export declare const foldRight: <A, B>(onEmpty: LazyArg<B>, onNonEmpty: (init: A[], last: A) => B) => (as: A[]) => B

Added in v2.0.0 v2.0.0 中添加

match   匹配

Takes an array, if the array is empty it returns the result of onEmpty, otherwise it passes the array to onNonEmpty and returns the result.
接受一个数组,如果数组为空则返回 onEmpty 的结果,否则将数组传递给 onNonEmpty 并返回结果。

Signature 签名

export declare const match: <B, A>(onEmpty: LazyArg<B>, onNonEmpty: (as: NEA.NonEmptyArray<A>) => B) => (as: A[]) => B

Example 例子

import { match } from 'fp-ts/Array'
import { pipe } from 'fp-ts/function'

const matcher = match(
  () => 'No elements',
  (as) => `Found ${as.length} element(s)`
)
assert.deepStrictEqual(pipe([1, 2, 3, 4], matcher), 'Found 4 element(s)')
assert.deepStrictEqual(pipe([], matcher), 'No elements')

Added in v2.11.0 v2.11.0 中添加

matchLeft   左匹配

Takes an array, if the array is empty it returns the result of onEmpty, otherwise it passes the array to onNonEmpty broken into its first element and remaining elements.
接受一个数组,如果数组为空,则返回 onEmpty 的结果,否则将数组传递给 onNonEmpty ,分解为第一个元素和其余元素。

Signature 签名

export declare const matchLeft: <B, A>(onEmpty: LazyArg<B>, onNonEmpty: (head: A, tail: A[]) => B) => (as: A[]) => B

Example 例子

import { matchLeft } from 'fp-ts/Array'

const len: <A>(as: Array<A>) => number = matchLeft(
  () => 0,
  (_, tail) => 1 + len(tail)
)
assert.strictEqual(len([1, 2, 3]), 3)

Added in v2.10.0 v2.10.0 中添加

matchLeftW   左匹配W

Less strict version of matchLeft. It will work when onEmpty and onNonEmpty have different return types.
matchLeft 的不太严格版本。当 onEmptyonNonEmpty 具有不同的返回类型时它将起作用。

Signature 签名

export declare const matchLeftW: <B, A, C>(
  onEmpty: LazyArg<B>,
  onNonEmpty: (head: A, tail: A[]) => C
) => (as: A[]) => B | C

Example 例子

import { matchLeftW } from 'fp-ts/Array'

const f = matchLeftW(
  () => 0,
  (head: string, tail: string[]) => `Found "${head}" followed by ${tail.length} elements`
)
assert.strictEqual(f(['a', 'b', 'c']), 'Found "a" followed by 2 elements')
assert.strictEqual(f([]), 0)

Added in v2.11.0 v2.11.0 中添加

matchRight   右匹配

Takes an array, if the array is empty it returns the result of onEmpty, otherwise it passes the array to onNonEmpty broken into its initial elements and the last element.
接受一个数组,如果数组为空,则返回 onEmpty 的结果,否则将数组传递给 onNonEmpty ,分解为初始元素和最后一个元素。

Signature 签名

export declare const matchRight: <B, A>(onEmpty: LazyArg<B>, onNonEmpty: (init: A[], last: A) => B) => (as: A[]) => B

Example 例子

import { matchRight } from 'fp-ts/Array'

const len: <A>(as: Array<A>) => number = matchRight(
  () => 0,
  (head, _) => 1 + len(head)
)
assert.strictEqual(len([1, 2, 3]), 3)

Added in v2.10.0 v2.10.0 中添加

matchRightW   匹配右W

Less strict version of matchRight. It will work when onEmpty and onNonEmpty have different return types.
matchRight 的不太严格版本。当 onEmptyonNonEmpty 具有不同的返回类型时它将起作用。

Signature 签名

export declare const matchRightW: <B, A, C>(
  onEmpty: LazyArg<B>,
  onNonEmpty: (init: A[], last: A) => C
) => (as: A[]) => B | C

Example 例子

import { matchRightW } from 'fp-ts/Array'

const f = matchRightW(
  () => 0,
  (head: string[], tail: string) => `Found ${head.length} elements folllowed by "${tail}"`
)
assert.strictEqual(f(['a', 'b', 'c']), 'Found 2 elements folllowed by "c"')
assert.strictEqual(f([]), 0)

Added in v2.11.0 v2.11.0 中添加

matchW   匹配W

Less strict version of match.
match 的不太严格版本。

The W suffix (short for Widening) means that the handler return types will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const matchW: <B, A, C>(
  onEmpty: LazyArg<B>,
  onNonEmpty: (as: NEA.NonEmptyArray<A>) => C
) => (as: A[]) => B | C

Example 例子

import { matchW } from 'fp-ts/Array'
import { pipe } from 'fp-ts/function'

const matcherW = matchW(
  () => 'No elements',
  (as) => as.length
)
assert.deepStrictEqual(pipe([1, 2, 3, 4], matcherW), 4)
assert.deepStrictEqual(pipe([], matcherW), 'No elements')

Added in v2.11.0 v2.11.0 中添加

refinements   改进

isEmpty   是空的

Test whether an array is empty
测试数组是否为空

Signature 签名

export declare const isEmpty: <A>(as: A[]) => as is []

Example 例子

import { isEmpty } from 'fp-ts/Array'

assert.strictEqual(isEmpty([]), true)
assert.strictEqual(isEmpty(['a']), false)

Added in v2.0.0 v2.0.0 中添加

isNonEmpty   为非空

Test whether an array is non empty narrowing down the type to NonEmptyArray<A>
测试数组是否非空,将类型范围缩小到 NonEmptyArray<A>

Signature 签名

export declare const isNonEmpty: <A>(as: A[]) => as is NEA.NonEmptyArray<A>

Example 例子

import { isNonEmpty } from 'fp-ts/Array'

assert.strictEqual(isNonEmpty([]), false)
assert.strictEqual(isNonEmpty(['a']), true)

Added in v2.0.0 v2.0.0 中添加

sequencing   测序

chainFirst   链优先

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const chainFirst: <A, B>(f: (a: A) => B[]) => (first: A[]) => A[]

Example 例子

import * as A from 'fp-ts/Array'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(
  pipe(
    [1, 2, 3],
    A.chainFirst(() => ['a', 'b'])
  ),
  [1, 1, 2, 2, 3, 3]
)
assert.deepStrictEqual(
  pipe(
    [1, 2, 3],
    A.chainFirst(() => [])
  ),
  []
)

Added in v2.0.0 v2.0.0 中添加

chainRecBreadthFirst   链记录宽度优先

Signature 签名

export declare const chainRecBreadthFirst: <A, B>(f: (a: A) => Either<A, B>[]) => (a: A) => B[]

Added in v2.11.0 v2.11.0 中添加

chainRecDepthFirst   链记录深度优先

Signature 签名

export declare const chainRecDepthFirst: <A, B>(f: (a: A) => Either<A, B>[]) => (a: A) => B[]

Added in v2.11.0 v2.11.0 中添加

chainWithIndex   带索引的链

Same as chain, but passing also the index to the iterating function.
chain 相同,但还将索引传递给迭代函数。

Signature 签名

export declare const chainWithIndex: <A, B>(f: (i: number, a: A) => B[]) => (as: A[]) => B[]

Example 例子

import { chainWithIndex, replicate } from 'fp-ts/Array'
import { pipe } from 'fp-ts/function'

const f = (index: number, x: string) => replicate(2, `${x}${index}`)
assert.deepStrictEqual(pipe(['a', 'b', 'c'], chainWithIndex(f)), ['a0', 'a0', 'b1', 'b1', 'c2', 'c2'])

Added in v2.7.0 v2.7.0 中添加

flatMap   平面地图

Composes computations in sequence, using the return value of one computation to determine the next computation.
按顺序组成计算,使用一次计算的返回值来确定下一次计算。

In other words it takes a function f that produces an array from a single element of the base type A and returns a new function which applies f to each element of the input array (like map) and, instead of returning an array of arrays, concatenates the results into a single array (like flatten).
换句话说,它采用一个函数 f ,该函数从基本类型 A 的单个元素生成一个数组,并返回一个新函数,该函数将 f 应用于输入数组的每个元素(如 map ),并且,不是返回数组的数组,而是将结果连接到单个数组中(如 flatten )。

Signature 签名

export declare const flatMap: {
  <A, B>(f: (a: A, i: number) => B[]): (ma: A[]) => B[]
  <A, B>(ma: A[], f: (a: A, i: number) => B[]): B[]
}

Example 例子

import { flatMap, map, replicate } from 'fp-ts/Array'
import { pipe } from 'fp-ts/function'

const f = (n: number) => replicate(n, `${n}`)
assert.deepStrictEqual(pipe([1, 2, 3], map(f)), [['1'], ['2', '2'], ['3', '3', '3']])
assert.deepStrictEqual(pipe([1, 2, 3], flatMap(f)), ['1', '2', '2', '3', '3', '3'])

Added in v2.14.0 v2.14.0 中添加

flatten   压扁

Takes an array of arrays of A and flattens them into an array of A by concatenating the elements of each array in order.
获取 A 数组的数组,并通过按顺序连接每个数组的元素将它们展平为 A 数组。

Signature 签名

export declare const flatten: <A>(mma: A[][]) => A[]

Example 例子

import { flatten } from 'fp-ts/Array'

assert.deepStrictEqual(flatten([['a'], ['b', 'c'], ['d', 'e', 'f']]), ['a', 'b', 'c', 'd', 'e', 'f'])

Added in v2.5.0 v2.5.0中添加

traverseWithIndex   索引遍历

Same as traverse but passing also the index to the iterating function.
traverse 相同,但还将索引传递给迭代函数。

Signature 签名

export declare const traverseWithIndex: PipeableTraverseWithIndex1<'Array', number>

Example 例子

import { traverseWithIndex } from 'fp-ts/Array'
import { Applicative, left, right } from 'fp-ts/lib/Either'

const f = (index: number, x: unknown) =>
  typeof x === 'string' ? right(x.toUpperCase() + index) : left(new Error('not a string'))
assert.deepStrictEqual(traverseWithIndex(Applicative)(f)(['a', 'b']), right(['A0', 'B1']))
assert.deepStrictEqual(traverseWithIndex(Applicative)(f)(['a', 5]), left(new Error('not a string')))

Added in v2.6.3 v2.6.3 中添加

traversing   穿越

sequence   顺序

sequence takes an Array where elements are HKT<A> (higher kinded type) and, using an applicative of that HKT, returns an HKT of Array<A>. E.g. it can turn an Array<Either<Error, string>> into an Either<Error, Array<string>>.
sequence 采用 Array ,其中元素为 HKT<A> (高级类型),并使用 HKT 的应用,返回 Array<A>HKT 。例如。它可以将 Array<Either<Error, string>> 变成 Either<Error, Array<string>>

sequence requires an Applicative of the HKT you are targeting, e.g. to turn an Array<Either<E, A>> into an Either<E, Array<A>>, it needs an Applicative for Either, to to turn an Array<Option<A>> into an Option<Array<A>>, it needs an Applicative for Option.
sequence 需要您所定位的 HKTApplicative ,例如将 Array<Either<E, A>> 变成 Either<E, Array<A>>Either 需要 Applicative ,将 Array<Option<A>> 变成 Option<Array<A>>Option 需要 Applicative

Signature 签名

export declare const sequence: Sequence1<'Array'>

Example 例子

import { sequence } from 'fp-ts/Array'
import { Applicative, left, right } from 'fp-ts/lib/Either'

assert.deepStrictEqual(sequence(Applicative)([right('a'), right('b')]), right(['a', 'b']))
assert.deepStrictEqual(
  sequence(Applicative)([right('a'), left(new Error('not a string'))]),
  left(new Error('not a string'))
)

Added in v2.6.3 v2.6.3 中添加

traverse   遍历

Given an iterating function that returns a HKT (higher kinded type), traverse applies the iterating function to each element of the Array and then sequence-s the results using the provided Applicative.
给定一个返回 HKT (更高种类类型)的迭代函数, traverse 将迭代函数应用于 Array 的每个元素,然后使用提供的 Applicative sequence -s 结果。

E.g. suppose you have an Array and you want to format each element with a function that returns a result or an error as f = (a: A) => Either<Error, B>, using traverse you can apply f to all elements and directly obtain as a result an Either<Error,Array<B>> i.e. an Array<B> if all the results are B, or an Error if some of the results are Errors.
例如。假设您有一个 Array 并且您想要使用返回结果或错误的函数格式化每个元素作为 f = (a: A) => Either<Error, B> ,使用 traverse 您可以将 f 应用于所有元素并直接获得 @ 作为结果4#,即如果所有结果都是 B ,则为 Array<B> ;如果某些结果是 Error ,则为 Error

Signature 签名

export declare const traverse: PipeableTraverse1<'Array'>

Example 例子

import { traverse } from 'fp-ts/Array'
import { Applicative, left, right } from 'fp-ts/lib/Either'

const f = (x: unknown) => (typeof x === 'string' ? right(x.toUpperCase()) : left(new Error('not a string')))
assert.deepStrictEqual(traverse(Applicative)(f)(['a', 'b']), right(['A', 'B']))
assert.deepStrictEqual(traverse(Applicative)(f)(['a', 5]), left(new Error('not a string')))

Added in v2.6.3 v2.6.3 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'Array'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

unsafe   不安全

unsafeDeleteAt  不安全删除

Signature 签名

export declare const unsafeDeleteAt: <A>(i: number, as: A[]) => A[]

Added in v2.0.0 v2.0.0 中添加

unsafeInsertAt   不安全插入

Signature 签名

export declare const unsafeInsertAt: <A>(i: number, a: A, as: A[]) => NEA.NonEmptyArray<A>

Added in v2.0.0 v2.0.0 中添加

unsafeUpdateAt  不安全更新处

Signature 签名

export declare const unsafeUpdateAt: <A>(i: number, a: A, as: A[]) => A[]

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

Spanned (interface)   跨越(接口)

Type returned by spanLeft composed of an init array and a rest array.
spanLeft 返回的类型由 init 数组和 rest 数组组成。

Signature 签名

export interface Spanned<I, R> {
  init: Array<I>
  rest: Array<R>
}

Added in v2.10.0 v2.10.0 中添加

ap   美联社

Signature 签名

export declare const ap: <A>(fa: A[]) => <B>(fab: ((a: A) => B)[]) => B[]

Example 例子

import { ap, map, of } from 'fp-ts/Array'
import { pipe } from 'fp-ts/function'

// a curried function with 3 input parameteres
const f = (s1: string) => (n: number) => (s2: string) => s1 + n + s2

// let's use `ap` to iterate `f` over an array for each input parameter
assert.deepStrictEqual(pipe(['a', 'b'], map(f), ap([1, 2]), ap(['😀', '😫', '😎'])), [
  'a1😀',
  'a1😫',
  'a1😎',
  'a2😀',
  'a2😫',
  'a2😎',
  'b1😀',
  'b1😫',
  'b1😎',
  'b2😀',
  'b2😫',
  'b2😎',
])

// given Array implements the Applicative interface with the `of` method,
// we can write exactly the same thing in a more symmetric way
// using `of` on `f` and `ap` on each array in input
assert.deepStrictEqual(
  pipe(of(f), ap(['a', 'b']), ap([1, 2]), ap(['😀', '😫', '😎'])),
  pipe(['a', 'b'], map(f), ap([1, 2]), ap(['😀', '😫', '😎']))
)

Added in v2.0.0 v2.0.0 中添加

apFirst   应用程序第一

Combine two effectful actions, keeping only the result of the first.
结合两个有效的操作,仅保留第一个操作的结果。

Signature 签名

export declare const apFirst: <B>(second: B[]) => <A>(first: A[]) => A[]

Added in v2.5.0 v2.5.0中添加

apSecond   ap秒

Combine two effectful actions, keeping only the result of the second.
结合两个有效的操作,只保留第二个的结果。

Signature 签名

export declare const apSecond: <B>(second: B[]) => <A>(first: A[]) => B[]

Added in v2.5.0 v2.5.0中添加

append   附加

Append an element to the end of a Array, creating a new NonEmptyArray.
将一个元素附加到 Array 的末尾,创建一个新的 NonEmptyArray

Signature 签名

export declare const append: <A>(end: A) => (init: A[]) => NEA.NonEmptyArray<A>

Example 例子

import { append } from 'fp-ts/Array'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe([1, 2, 3], append(4)), [1, 2, 3, 4])

Added in v2.10.0 v2.10.0 中添加

appendW   追加W

Less strict version of append.
append 的不太严格版本。

Signature 签名

export declare const appendW: <A, B>(end: B) => (init: A[]) => NEA.NonEmptyArray<A | B>

Example 例子

import { appendW } from 'fp-ts/Array'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe([1, 2, 3], appendW('d')), [1, 2, 3, 'd'])

Added in v2.11.0 v2.11.0 中添加

chop  

A useful recursion pattern for processing an array to produce a new array, often used for “chopping” up the input array. Typically chop is called with some function that will consume an initial prefix of the array and produce a value and the rest of the array.
一种有用的递归模式,用于处理数组以生成新数组,通常用于“切碎”输入数组。通常,chop 是通过某个函数调用的,该函数将消耗数组的初始前缀并生成一个值和数组的其余部分。

Signature 签名

export declare const chop: <A, B>(f: (as: NEA.NonEmptyArray<A>) => [B, A[]]) => (as: A[]) => B[]

Example 例子

import { Eq } from 'fp-ts/Eq'
import * as A from 'fp-ts/Array'
import * as N from 'fp-ts/number'
import { pipe } from 'fp-ts/function'

const group = <A>(S: Eq<A>): ((as: Array<A>) => Array<Array<A>>) => {
  return A.chop((as) => {
    const { init, rest } = pipe(
      as,
      A.spanLeft((a: A) => S.equals(a, as[0]))
    )
    return [init, rest]
  })
}
assert.deepStrictEqual(group(N.Eq)([1, 1, 2, 3, 3, 4]), [[1, 1], [2], [3, 3], [4]])

Added in v2.0.0 v2.0.0 中添加

chunksOf   大块

Splits an array into length-n pieces. The last piece will be shorter if n does not evenly divide the length of the array. Note that chunksOf(n)([]) is [], not [[]]. This is intentional, and is consistent with a recursive definition of chunksOf; it satisfies the property that
将数组分割成长度为 n 的片段。如果 n 没有均匀划分数组的长度,那么最后一段会更短。请注意, chunksOf(n)([])[] ,而不是 [[]] 。这是故意的,并且与 chunksOf 的递归定义一致;它满足以下性质

chunksOf(n)(xs).concat(chunksOf(n)(ys)) == chunksOf(n)(xs.concat(ys)))

whenever n evenly divides the length of xs.
每当 n 均分 xs 的长度时。

Signature 签名

export declare const chunksOf: (n: number) => <A>(as: A[]) => NEA.NonEmptyArray<A>[]

Example 例子

import { chunksOf } from 'fp-ts/Array'

assert.deepStrictEqual(chunksOf(2)([1, 2, 3, 4, 5]), [[1, 2], [3, 4], [5]])

Added in v2.0.0 v2.0.0 中添加

comprehension   理解

Array comprehension.

[ f(x, y, ...) | x ← xs, y ← ys, ..., g(x, y, ...) ]

Signature 签名

export declare function comprehension<A, B, C, D, R>(
  input: [Array<A>, Array<B>, Array<C>, Array<D>],
  f: (a: A, b: B, c: C, d: D) => R,
  g?: (a: A, b: B, c: C, d: D) => boolean
): Array<R>
export declare function comprehension<A, B, C, R>(
  input: [Array<A>, Array<B>, Array<C>],
  f: (a: A, b: B, c: C) => R,
  g?: (a: A, b: B, c: C) => boolean
): Array<R>
export declare function comprehension<A, B, R>(
  input: [Array<A>, Array<B>],
  f: (a: A, b: B) => R,
  g?: (a: A, b: B) => boolean
): Array<R>
export declare function comprehension<A, R>(input: [Array<A>], f: (a: A) => R, g?: (a: A) => boolean): Array<R>

Example 例子

import { comprehension } from 'fp-ts/Array'
import { tuple } from 'fp-ts/function'

assert.deepStrictEqual(
  comprehension(
    [
      [1, 2, 3],
      ['a', 'b'],
    ],
    tuple,
    (a, b) => (a + b.length) % 2 === 0
  ),
  [
    [1, 'a'],
    [1, 'b'],
    [3, 'a'],
    [3, 'b'],
  ]
)

Added in v2.0.0 v2.0.0 中添加

concat   连接

Signature 签名

export declare const concat: <A>(second: A[]) => (first: A[]) => A[]

Added in v2.11.0 v2.11.0 中添加

concatW   连接W

Signature 签名

export declare const concatW: <B>(second: B[]) => <A>(first: A[]) => (B | A)[]

Added in v2.11.0 v2.11.0 中添加

copy   复制

This function takes an array and makes a new array containing the same elements.
该函数接受一个数组并创建一个包含相同元素的新数组。

Signature 签名

export declare const copy: <A>(as: A[]) => A[]

Added in v2.0.0 v2.0.0 中添加

deleteAt   删除处

Delete the element at the specified index, creating a new array, or returning None if the index is out of bounds.
删除指定索引处的元素,创建一个新数组,或者如果索引越界则返回 None

Signature 签名

export declare const deleteAt: (i: number) => <A>(as: A[]) => Option<A[]>

Example 例子

import { deleteAt } from 'fp-ts/Array'
import { some, none } from 'fp-ts/Option'

assert.deepStrictEqual(deleteAt(0)([1, 2, 3]), some([2, 3]))
assert.deepStrictEqual(deleteAt(1)([]), none)

Added in v2.0.0 v2.0.0 中添加

difference   不同之处

Creates an array of array values not included in the other given array using a Eq for equality comparisons. The order and references of result values are determined by the first array.
使用 Eq 创建不包含在其他给定数组中的数组值进行相等比较。结果值的顺序和引用由第一个数组确定。

Signature 签名

export declare function difference<A>(E: Eq<A>): {
  (xs: Array<A>): (ys: Array<A>) => Array<A>
  (xs: Array<A>, ys: Array<A>): Array<A>
}

Example 例子

import { difference } from 'fp-ts/Array'
import * as N from 'fp-ts/number'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe([1, 2], difference(N.Eq)([2, 3])), [1])

Added in v2.0.0 v2.0.0 中添加

dropLeft   向左下降

Creates a new Array which is a copy of the input dropping a max number of elements from the start.
创建一个新的 Array ,它是输入的副本,从开头删除最大数量的元素。

Note. n is normalized to a non negative integer.
笔记。 n 被标准化为非负整数。

Signature 签名

export declare const dropLeft: (n: number) => <A>(as: A[]) => A[]

Example 例子

import { dropLeft } from 'fp-ts/Array'

assert.deepStrictEqual(dropLeft(2)([1, 2, 3]), [3])
assert.deepStrictEqual(dropLeft(5)([1, 2, 3]), [])
assert.deepStrictEqual(dropLeft(0)([1, 2, 3]), [1, 2, 3])
assert.deepStrictEqual(dropLeft(-2)([1, 2, 3]), [1, 2, 3])

Added in v2.0.0 v2.0.0 中添加

dropLeftWhile   向左下降

Creates a new Array which is a copy of the input dropping the longest initial subarray for which all element satisfy the specified predicate.
创建一个新的 Array ,它是输入的副本,删除所有元素都满足指定谓词的最长初始子数组。

Signature 签名

export declare function dropLeftWhile<A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Array<B>
export declare function dropLeftWhile<A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Array<B>
export declare function dropLeftWhile<A>(predicate: Predicate<A>): (as: Array<A>) => Array<A>

Example 例子

import { dropLeftWhile } from 'fp-ts/Array'

assert.deepStrictEqual(dropLeftWhile((n: number) => n % 2 === 1)([1, 3, 2, 4, 5]), [2, 4, 5])

Added in v2.0.0 v2.0.0 中添加

dropRight   向右下降

Creates a new Array which is a copy of the input dropping a max number of elements from the end.
创建一个新的 Array ,它是输入的副本,从末尾删除最大数量的元素。

Note. n is normalized to a non negative integer.
笔记。 n 被标准化为非负整数。

Signature 签名

export declare const dropRight: (n: number) => <A>(as: A[]) => A[]

Example 例子

import { dropRight } from 'fp-ts/Array'

assert.deepStrictEqual(dropRight(2)([1, 2, 3]), [1])
assert.deepStrictEqual(dropRight(5)([1, 2, 3]), [])
assert.deepStrictEqual(dropRight(0)([1, 2, 3]), [1, 2, 3])
assert.deepStrictEqual(dropRight(-2)([1, 2, 3]), [1, 2, 3])

Added in v2.0.0 v2.0.0 中添加

duplicate   复制

duplicate returns an array containing the whole input Array, then to the input Array dropping the first element, then to the input Array dropping the first two elements, etc.
duplicate 返回一个包含整个输入 Array 的数组,然后返回到输入 Array 删除第一个元素,然后返回到输入 Array 删除前两个元素,依此类推。

Signature 签名

export declare const duplicate: <A>(wa: A[]) => A[][]

Example 例子

import { duplicate } from 'fp-ts/Array'

assert.deepStrictEqual(duplicate(['a', 'b', 'c']), [['a', 'b', 'c'], ['b', 'c'], ['c']])

Added in v2.0.0 v2.0.0 中添加

elem   埃莱姆

Test if a value is a member of an Array. Takes a Eq<A> as a single argument which returns the function to use to search for a value of type A in an Array<A>.
测试某个值是否是 Array 的成员。将 Eq<A> 作为单个参数,返回用于在 Array<A> 中搜索 A 类型的值的函数。

Signature 签名

export declare const elem: <A>(E: Eq<A>) => { (a: A): (as: A[]) => boolean; (a: A, as: A[]): boolean }

Example 例子

import { elem } from 'fp-ts/Array'
import * as N from 'fp-ts/number'
import { pipe } from 'fp-ts/function'

assert.strictEqual(pipe([1, 2, 3], elem(N.Eq)(2)), true)
assert.strictEqual(pipe([1, 2, 3], elem(N.Eq)(0)), false)

Added in v2.0.0 v2.0.0 中添加

every   每一个

every tells if the provided predicate holds true for every element in the Array.
every 告诉所提供的谓词是否对于 Array 中的每个元素都成立。

Signature 签名

export declare const every: {
  <A, B extends A>(refinement: Refinement<A, B>): Refinement<A[], B[]>
  <A>(predicate: Predicate<A>): Predicate<A[]>
}

Example 例子

import { every } from 'fp-ts/Array'

assert.equal(every((x: number) => x >= 0)([1, 2, 3]), true)
assert.equal(every((x: number) => x >= 0)([-1, 2, 3]), false)

Added in v2.9.0 v2.9.0中添加

exists   存在

Alias of some  some 的别名

Signature 签名

export declare const exists: <A>(predicate: Predicate<A>) => (as: A[]) => as is NEA.NonEmptyArray<A>

Added in v2.11.0 v2.11.0 中添加

extend   延长

Given an iterating function that takes Array<A> as input, extend returns an array containing the results of the iterating function applied to the whole input Array, then to the input Array without the first element, then to the input Array without the first two elements, etc.
给定一个以 Array<A> 作为输入的迭代函数, extend 返回一个数组,其中包含迭代函数的结果,该迭代函数应用于整个输入 Array ,然后应用于没有第一个元素的输入 Array ,然后应用于输入 Array 没有前两个元素,等等。

Signature 签名

export declare const extend: <A, B>(f: (as: A[]) => B) => (as: A[]) => B[]

Example 例子

import { extend } from 'fp-ts/Array'

const f = (a: string[]) => a.join(',')
assert.deepStrictEqual(extend(f)(['a', 'b', 'c']), ['a,b,c', 'b,c', 'c'])

Added in v2.0.0 v2.0.0 中添加

filterE   过滤器E

Filter values inside a context.
过滤上下文中的值。

Signature 签名

export declare const filterE: FilterE1<'Array'>

Added in v2.11.0 v2.11.0 中添加

findFirst   查找第一个

Find the first element which satisfies a predicate (or a refinement) function. It returns an Option containing the element or None if not found.
查找满足谓词(或细化)函数的第一个元素。它返回包含该元素的 Option ,如果未找到则返回 None

Signature 签名

export declare function findFirst<A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Option<B>
export declare function findFirst<A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Option<B>
export declare function findFirst<A>(predicate: Predicate<A>): (as: Array<A>) => Option<A>

Example 例子

import { findFirst } from 'fp-ts/Array'
import { some } from 'fp-ts/Option'

type X = {
  readonly a: number
  readonly b: number
}

assert.deepStrictEqual(
  findFirst((x: X) => x.a === 1)([
    { a: 1, b: 1 },
    { a: 1, b: 2 },
  ]),
  some({ a: 1, b: 1 })
)

Added in v2.0.0 v2.0.0 中添加

findFirstMap   查找第一张地图

Given a selector function which takes an element and returns an option, this function applies the selector to each element of the array and returns the first Some result. Otherwise it returns None.
给定一个接受一个元素并返回一个选项的选择器函数,该函数将选择器应用于数组的每个元素并返回第一个 Some 结果。否则返回 None

Signature 签名

export declare const findFirstMap: <A, B>(f: (a: A) => Option<B>) => (as: A[]) => Option<B>

Example 例子

import { findFirstMap } from 'fp-ts/Array'
import { some, none } from 'fp-ts/Option'

interface Person {
  readonly name: string
  readonly age: number
}

const persons: Array<Person> = [
  { name: 'John', age: 16 },
  { name: 'Mary', age: 45 },
  { name: 'Joey', age: 28 },
]

const nameOfPersonAbove18 = (p: Person) => (p.age <= 18 ? none : some(p.name))
const nameOfPersonAbove70 = (p: Person) => (p.age <= 70 ? none : some(p.name))
assert.deepStrictEqual(findFirstMap(nameOfPersonAbove18)(persons), some('Mary'))
assert.deepStrictEqual(findFirstMap(nameOfPersonAbove70)(persons), none)

Added in v2.0.0 v2.0.0 中添加

findIndex   查找索引

findIndex returns an Option containing the first index for which a predicate holds. It returns None if no element satisfies the predicate. Similar to findFirst but returning the index instead of the element.
findIndex 返回一个 Option ,其中包含谓词所保留的第一个索引。如果没有元素满足谓词,则返回 None 。与 findFirst 类似,但返回索引而不是元素。

Signature 签名

export declare const findIndex: <A>(predicate: Predicate<A>) => (as: A[]) => Option<number>

Example 例子

import { findIndex } from 'fp-ts/Array'
import { some, none } from 'fp-ts/Option'

assert.deepStrictEqual(findIndex((n: number) => n === 2)([1, 2, 3]), some(1))
assert.deepStrictEqual(findIndex((n: number) => n === 2)([]), none)

Added in v2.0.0 v2.0.0 中添加

findLast   查找最后一个

Find the last element which satisfies a predicate function. It returns an Option containing the element or None if not found.
找到满足谓词函数的最后一个元素。它返回包含该元素的 Option ,如果未找到则返回 None

Signature 签名

export declare function findLast<A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Option<B>
export declare function findLast<A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Option<B>
export declare function findLast<A>(predicate: Predicate<A>): (as: Array<A>) => Option<A>

Example 例子

import { findLast } from 'fp-ts/Array'
import { some } from 'fp-ts/Option'

type X = {
  readonly a: number
  readonly b: number
}

assert.deepStrictEqual(
  findLast((x: X) => x.a === 1)([
    { a: 1, b: 1 },
    { a: 1, b: 2 },
  ]),
  some({ a: 1, b: 2 })
)

Added in v2.0.0 v2.0.0 中添加

findLastIndex  查找最后一个索引

Returns the index of the last element of the list which matches the predicate. It returns an Option containing the index or None if not found.
返回列表中与谓词匹配的最后一个元素的索引。它返回包含索引的 Option ,如果未找到则返回 None

Signature 签名

export declare const findLastIndex: <A>(predicate: Predicate<A>) => (as: A[]) => Option<number>

Example 例子

import { findLastIndex } from 'fp-ts/Array'
import { some, none } from 'fp-ts/Option'

interface X {
  readonly a: number
  readonly b: number
}
const xs: Array<X> = [
  { a: 1, b: 0 },
  { a: 1, b: 1 },
]
assert.deepStrictEqual(findLastIndex((x: { readonly a: number }) => x.a === 1)(xs), some(1))
assert.deepStrictEqual(findLastIndex((x: { readonly a: number }) => x.a === 4)(xs), none)

Added in v2.0.0 v2.0.0 中添加

findLastMap   查找最后一个地图

Given a selector function which takes an element and returns an option, this function applies the selector to each element of the array starting from the end and returns the last Some result. Otherwise it returns None.
给定一个接受一个元素并返回一个选项的选择器函数,该函数将选择器从末尾开始应用于数组的每个元素,并返回最后一个 Some 结果。否则返回 None

Signature 签名

export declare const findLastMap: <A, B>(f: (a: A) => Option<B>) => (as: A[]) => Option<B>

Example 例子

import { findLastMap } from 'fp-ts/Array'
import { some, none } from 'fp-ts/Option'

interface Person {
  readonly name: string
  readonly age: number
}

const persons: Array<Person> = [
  { name: 'John', age: 16 },
  { name: 'Mary', age: 45 },
  { name: 'Joey', age: 28 },
]

const nameOfPersonAbove18 = (p: Person) => (p.age <= 18 ? none : some(p.name))
const nameOfPersonAbove70 = (p: Person) => (p.age <= 70 ? none : some(p.name))
assert.deepStrictEqual(findLastMap(nameOfPersonAbove18)(persons), some('Joey'))
assert.deepStrictEqual(findLastMap(nameOfPersonAbove70)(persons), none)

Added in v2.0.0 v2.0.0 中添加

Get the first element in an array, or None if the array is empty
获取数组中的第一个元素,如果数组为空则获取 None

Signature 签名

export declare const head: <A>(as: A[]) => Option<A>

Example 例子

import { head } from 'fp-ts/Array'
import { some, none } from 'fp-ts/Option'

assert.deepStrictEqual(head([1, 2, 3]), some(1))
assert.deepStrictEqual(head([]), none)

Added in v2.0.0 v2.0.0 中添加

init   在里面

Get all but the last element of an array, creating a new array, or None if the array is empty
获取数组中除最后一个元素之外的所有元素,创建一个新数组,如果数组为空则为 None

Signature 签名

export declare const init: <A>(as: A[]) => Option<A[]>

Example 例子

import { init } from 'fp-ts/Array'
import { some, none } from 'fp-ts/Option'

assert.deepStrictEqual(init([1, 2, 3]), some([1, 2]))
assert.deepStrictEqual(init([]), none)

Added in v2.0.0 v2.0.0 中添加

insertAt   插入位置

Insert an element at the specified index, creating a new array, or returning None if the index is out of bounds.
在指定索引处插入一个元素,创建一个新数组,或者如果索引越界则返回 None

Signature 签名

export declare const insertAt: <A>(i: number, a: A) => (as: A[]) => Option<NEA.NonEmptyArray<A>>

Example 例子

import { insertAt } from 'fp-ts/Array'
import { some } from 'fp-ts/Option'

assert.deepStrictEqual(insertAt(2, 5)([1, 2, 3, 4]), some([1, 2, 5, 3, 4]))

Added in v2.0.0 v2.0.0 中添加

intercalate  

Places an element in between members of an Array, then folds the results using the provided Monoid.
将一个元素放置在 Array 的成员之间,然后使用提供的 Monoid 折叠结果。

Signature 签名

export declare const intercalate: <A>(M: Monoid<A>) => (middle: A) => (as: A[]) => A

Example 例子

import * as S from 'fp-ts/string'
import { intercalate } from 'fp-ts/Array'

assert.deepStrictEqual(intercalate(S.Monoid)('-')(['a', 'b', 'c']), 'a-b-c')

Added in v2.12.0 v2.12.0 中添加

intersection   路口

Creates an array of unique values that are included in all given arrays using a Eq for equality comparisons. The order and references of result values are determined by the first array.
创建一个包含在所有给定数组中的唯一值数组,使用 Eq 进行相等比较。结果值的顺序和引用由第一个数组确定。

Signature 签名

export declare function intersection<A>(E: Eq<A>): {
  (xs: Array<A>): (ys: Array<A>) => Array<A>
  (xs: Array<A>, ys: Array<A>): Array<A>
}

Example 例子

import { intersection } from 'fp-ts/Array'
import * as N from 'fp-ts/number'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe([1, 2], intersection(N.Eq)([2, 3])), [2])

Added in v2.0.0 v2.0.0 中添加

intersperse   散布

Creates a new Array placing an element in between members of the input Array.
创建一个新的 Array ,将一个元素放置在输入 Array 的成员之间。

Signature 签名

export declare const intersperse: <A>(middle: A) => (as: A[]) => A[]

Example 例子

import { intersperse } from 'fp-ts/Array'

assert.deepStrictEqual(intersperse(9)([1, 2, 3, 4]), [1, 9, 2, 9, 3, 9, 4])

Added in v2.9.0 v2.9.0中添加

isOutOfBound   超出界限

Test whether an array contains a particular index
测试数组是否包含特定索引

Signature 签名

export declare const isOutOfBound: <A>(i: number, as: A[]) => boolean

Example 例子

import { isOutOfBound } from 'fp-ts/Array'

assert.strictEqual(isOutOfBound(1, ['a', 'b', 'c']), false)
assert.strictEqual(isOutOfBound(-1, ['a', 'b', 'c']), true)
assert.strictEqual(isOutOfBound(3, ['a', 'b', 'c']), true)

Added in v2.0.0 v2.0.0 中添加

last   最后的

Get the last element in an array, or None if the array is empty
获取数组中的最后一个元素,如果数组为空,则获取 None

Signature 签名

export declare const last: <A>(as: A[]) => Option<A>

Example 例子

import { last } from 'fp-ts/Array'
import { some, none } from 'fp-ts/Option'

assert.deepStrictEqual(last([1, 2, 3]), some(3))
assert.deepStrictEqual(last([]), none)

Added in v2.0.0 v2.0.0 中添加

lefts   左派

Takes an Array of Either and produces a new Array containing the values of all the Left elements in the same order.
获取 EitherArray 并生成一个新的 Array ,其中包含按相同顺序排列的所有 Left 元素的值。

Signature 签名

export declare const lefts: <E, A>(as: Either<E, A>[]) => E[]

Example 例子

import { lefts } from 'fp-ts/Array'
import { left, right } from 'fp-ts/Either'

assert.deepStrictEqual(lefts([right(1), left('foo'), right(2)]), ['foo'])

Added in v2.0.0 v2.0.0 中添加

lookup   抬头

This function provides a safe way to read a value at a particular index from an array. It returns a none if the index is out of bounds, and a some of the element if the index is valid.
此函数提供了一种从数组中读取特定索引处的值的安全方法。如果索引越界,则返回 none ;如果索引有效,则返回元素的 some

Signature 签名

export declare const lookup: { (i: number): <A>(as: A[]) => Option<A>; <A>(i: number, as: A[]): Option<A> }

Example 例子

import { lookup } from 'fp-ts/Array'
import { some, none } from 'fp-ts/Option'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe([1, 2, 3], lookup(1)), some(2))
assert.deepStrictEqual(pipe([1, 2, 3], lookup(3)), none)

Added in v2.0.0 v2.0.0 中添加

modifyAt   修改处

Apply a function to the element at the specified index, creating a new array, or returning None if the index is out of bounds.
将函数应用于指定索引处的元素,创建一个新数组,或者如果索引越界则返回 None

Signature 签名

export declare const modifyAt: <A>(i: number, f: (a: A) => A) => (as: A[]) => Option<A[]>

Example 例子

import { modifyAt } from 'fp-ts/Array'
import { some, none } from 'fp-ts/Option'

const double = (x: number): number => x * 2
assert.deepStrictEqual(modifyAt(1, double)([1, 2, 3]), some([1, 4, 3]))
assert.deepStrictEqual(modifyAt(1, double)([]), none)

Added in v2.0.0 v2.0.0 中添加

prepend   前置

Prepend an element to the front of a Array, creating a new NonEmptyArray.
Array 前面添加一个元素,创建一个新的 NonEmptyArray

Signature 签名

export declare const prepend: <A>(head: A) => (tail: A[]) => NEA.NonEmptyArray<A>

Example 例子

import { prepend } from 'fp-ts/Array'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe([2, 3, 4], prepend(1)), [1, 2, 3, 4])

Added in v2.10.0 v2.10.0 中添加

prependAll   前置所有

Creates a new Array, prepending an element to every member of the input Array.
创建一个新的 Array ,在输入 Array 的每个成员前面添加一个元素。

Signature 签名

export declare const prependAll: <A>(middle: A) => (as: A[]) => A[]

Example 例子

import { prependAll } from 'fp-ts/Array'

assert.deepStrictEqual(prependAll(9)([1, 2, 3, 4]), [9, 1, 9, 2, 9, 3, 9, 4])

Added in v2.10.0 v2.10.0 中添加

prependW   前置W

Less strict version of prepend.
prepend 的不太严格版本。

Signature 签名

export declare const prependW: <A, B>(head: B) => (tail: A[]) => NEA.NonEmptyArray<A | B>

Example 例子

import { prependW } from 'fp-ts/Array'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe([2, 3, 4], prependW('a')), ['a', 2, 3, 4])

Added in v2.11.0 v2.11.0 中添加

reverse   撤销

Reverse an array, creating a new array
反转数组,创建一个新数组

Signature 签名

export declare const reverse: <A>(as: A[]) => A[]

Example 例子

import { reverse } from 'fp-ts/Array'

assert.deepStrictEqual(reverse([1, 2, 3]), [3, 2, 1])

Added in v2.0.0 v2.0.0 中添加

rights   权利

Takes an Array of Either and produces a new Array containing the values of all the Right elements in the same order.
获取 EitherArray 并生成一个新的 Array ,其中包含按相同顺序排列的所有 Right 元素的值。

Signature 签名

export declare const rights: <E, A>(as: Either<E, A>[]) => A[]

Example 例子

import { rights } from 'fp-ts/Array'
import { right, left } from 'fp-ts/Either'

assert.deepStrictEqual(rights([right(1), left('foo'), right(2)]), [1, 2])

Added in v2.0.0 v2.0.0 中添加

rotate   旋转

Creates a new Array rotating the input Array by n steps.
创建一个新的 Array ,将输入 Array 旋转 n 步。

Signature 签名

export declare const rotate: (n: number) => <A>(as: A[]) => A[]

Example 例子

import { rotate } from 'fp-ts/Array'

assert.deepStrictEqual(rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])

Added in v2.0.0 v2.0.0 中添加

scanLeft   向左扫描

Same as reduce but it carries over the intermediate steps
reduce 相同,但它延续了中间步骤

Signature 签名

export declare const scanLeft: <A, B>(b: B, f: (b: B, a: A) => B) => (as: A[]) => NEA.NonEmptyArray<B>

Example 例子

import { scanLeft } from 'fp-ts/Array'

assert.deepStrictEqual(scanLeft(10, (b, a: number) => b - a)([1, 2, 3]), [10, 9, 7, 4])

Added in v2.0.0 v2.0.0 中添加

scanRight   右扫描

Fold an array from the right, keeping all intermediate results instead of only the final result
从右侧折叠数组,保留所有中间结果而不是仅保留最终结果

Signature 签名

export declare const scanRight: <A, B>(b: B, f: (a: A, b: B) => B) => (as: A[]) => NEA.NonEmptyArray<B>

Example 例子

import { scanRight } from 'fp-ts/Array'

assert.deepStrictEqual(scanRight(10, (a: number, b) => b - a)([1, 2, 3]), [4, 5, 7, 10])

Added in v2.0.0 v2.0.0 中添加

size   尺寸

Calculate the number of elements in a Array.
计算 Array 中的元素数量。

Signature 签名

export declare const size: <A>(as: A[]) => number

Example 例子

import { size } from 'fp-ts/Array'

assert.strictEqual(size(['a', 'b', 'c']), 3)

Added in v2.10.0 v2.10.0 中添加

some   一些

some tells if the provided predicate holds true at least for one element in the Array.
some 告知所提供的谓词是否至少对于 Array 中的一个元素成立。

Signature 签名

export declare const some: <A>(predicate: Predicate<A>) => (as: A[]) => as is NEA.NonEmptyArray<A>

Example 例子

import { some } from 'fp-ts/Array'

assert.equal(some((x: number) => x >= 0)([1, 2, 3]), true)
assert.equal(some((x: number) => x >= 10)([1, 2, 3]), false)

Added in v2.9.0 v2.9.0中添加

sort   种类

Sort the elements of an array in increasing order, creating a new array
将数组元素按升序排序,创建一个新数组

Signature 签名

export declare const sort: <B>(O: Ord<B>) => <A extends B>(as: A[]) => A[]

Example 例子

import { sort } from 'fp-ts/Array'
import * as N from 'fp-ts/number'

assert.deepStrictEqual(sort(N.Ord)([3, 2, 1]), [1, 2, 3])

Added in v2.0.0 v2.0.0 中添加

sortBy   排序方式

Sort the elements of an array in increasing order, where elements are compared using first ords[0], then ords[1], etc…
按升序对数组的元素进行排序,其中首先使用 ords[0] ,然后使用 ords[1] 等比较元素......

Signature 签名

export declare const sortBy: <B>(ords: Ord<B>[]) => <A extends B>(as: A[]) => A[]

Example 例子

import { sortBy } from 'fp-ts/Array'
import { contramap } from 'fp-ts/Ord'
import * as S from 'fp-ts/string'
import * as N from 'fp-ts/number'
import { pipe } from 'fp-ts/function'

interface Person {
  readonly name: string
  readonly age: number
}
const byName = pipe(
  S.Ord,
  contramap((p: Person) => p.name)
)
const byAge = pipe(
  N.Ord,
  contramap((p: Person) => p.age)
)

const sortByNameByAge = sortBy([byName, byAge])

const persons = [
  { name: 'a', age: 1 },
  { name: 'b', age: 3 },
  { name: 'c', age: 2 },
  { name: 'b', age: 2 },
]
assert.deepStrictEqual(sortByNameByAge(persons), [
  { name: 'a', age: 1 },
  { name: 'b', age: 2 },
  { name: 'b', age: 3 },
  { name: 'c', age: 2 },
])

Added in v2.0.0 v2.0.0 中添加

spanLeft   左跨距

Split an array into two parts:
将数组分成两部分:

  1. the longest initial subarray for which all elements satisfy the specified predicate
    所有元素满足指定谓词的最长初始子数组
  2. the remaining elements 剩余元素

Signature 签名

export declare function spanLeft<A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Spanned<B, A>
export declare function spanLeft<A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Spanned<B, B>
export declare function spanLeft<A>(predicate: Predicate<A>): (as: Array<A>) => Spanned<A, A>

Example 例子

import { spanLeft } from 'fp-ts/Array'

const isOdd = (n: number) => n % 2 === 1
assert.deepStrictEqual(spanLeft(isOdd)([1, 3, 2, 4, 5]), { init: [1, 3], rest: [2, 4, 5] })
assert.deepStrictEqual(spanLeft(isOdd)([0, 2, 4, 5]), { init: [], rest: [0, 2, 4, 5] })
assert.deepStrictEqual(spanLeft(isOdd)([1, 3, 5]), { init: [1, 3, 5], rest: [] })

Added in v2.0.0 v2.0.0 中添加

splitAt   分割点

Splits an Array into two pieces, the first piece has max n elements.
Array 分成两部分,第一部分最多包含 n 元素。

Signature 签名

export declare const splitAt: (n: number) => <A>(as: A[]) => [A[], A[]]

Example 例子

import { splitAt } from 'fp-ts/Array'

assert.deepStrictEqual(splitAt(2)([1, 2, 3, 4, 5]), [
  [1, 2],
  [3, 4, 5],
])

Added in v2.0.0 v2.0.0 中添加

tail   尾巴

Get all but the first element of an array, creating a new array, or None if the array is empty
获取数组中除第一个元素以外的所有元素,创建一个新数组,如果数组为空,则获取 None

Signature 签名

export declare const tail: <A>(as: A[]) => Option<A[]>

Example 例子

import { tail } from 'fp-ts/Array'
import { some, none } from 'fp-ts/Option'

assert.deepStrictEqual(tail([1, 2, 3]), some([2, 3]))
assert.deepStrictEqual(tail([]), none)

Added in v2.0.0 v2.0.0 中添加

takeLeft   左转

Keep only a max number of elements from the start of an Array, creating a new Array.
仅保留 Array 开头的最大数量的元素,创建新的 Array

Note. n is normalized to a non negative integer.
笔记。 n 被标准化为非负整数。

Signature 签名

export declare const takeLeft: (n: number) => <A>(as: A[]) => A[]

Example 例子

import { takeLeft } from 'fp-ts/Array'

assert.deepStrictEqual(takeLeft(2)([1, 2, 3, 4, 5]), [1, 2])
assert.deepStrictEqual(takeLeft(7)([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5])
assert.deepStrictEqual(takeLeft(0)([1, 2, 3, 4, 5]), [])
assert.deepStrictEqual(takeLeft(-1)([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5])

Added in v2.0.0 v2.0.0 中添加

takeLeftWhile   向左走

Calculate the longest initial subarray for which all element satisfy the specified predicate, creating a new array
计算所有元素满足指定谓词的最长初始子数组,创建一个新数组

Signature 签名

export declare function takeLeftWhile<A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Array<B>
export declare function takeLeftWhile<A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Array<B>
export declare function takeLeftWhile<A>(predicate: Predicate<A>): (as: Array<A>) => Array<A>

Example 例子

import { takeLeftWhile } from 'fp-ts/Array'

assert.deepStrictEqual(takeLeftWhile((n: number) => n % 2 === 0)([2, 4, 3, 6]), [2, 4])

Added in v2.0.0 v2.0.0 中添加

takeRight   右转

Keep only a max number of elements from the end of an Array, creating a new Array.
仅保留 Array 末尾的最大数量的元素,创建新的 Array

Note. n is normalized to a non negative integer.
笔记。 n 被标准化为非负整数。

Signature 签名

export declare const takeRight: (n: number) => <A>(as: A[]) => A[]

Example 例子

import { takeRight } from 'fp-ts/Array'

assert.deepStrictEqual(takeRight(2)([1, 2, 3, 4, 5]), [4, 5])
assert.deepStrictEqual(takeRight(7)([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5])
assert.deepStrictEqual(takeRight(0)([1, 2, 3, 4, 5]), [])
assert.deepStrictEqual(takeRight(-1)([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5])

Added in v2.0.0 v2.0.0 中添加

unfold   展开

unfold takes a function f which returns an Option of a tuple containing an outcome value and an input for the following iteration. unfold applies f to the initial value b and then recursively to the second element of the tuple contained in the returned option of the previous calculation until f returns Option.none.
unfold 接受一个函数 f ,该函数返回一个元组的 Option ,其中包含后续迭代的结果值和输入​​。 unfoldf 应用到初始值 b ,然后递归到先前计算返回的 option 中包含的元组的第二个元素,直到 f 返回 Option.none

Signature 签名

export declare const unfold: <A, B>(b: B, f: (b: B) => Option<readonly [A, B]>) => A[]

Example 例子

import { unfold } from 'fp-ts/Array'
import { option } from 'fp-ts'

const f = (n: number) => {
  if (n <= 0) return option.none
  const returnValue = n * 2
  const inputForNextRound = n - 1
  return option.some([returnValue, inputForNextRound] as const)
}
assert.deepStrictEqual(unfold(5, f), [10, 8, 6, 4, 2])

Added in v2.6.6 v2.6.6 中添加

union   联盟

Creates an array of unique values, in order, from all given arrays using a Eq for equality comparisons
使用 Eq 从所有给定数组中按顺序创建唯一值数组以进行相等比较

Signature 签名

export declare function union<A>(E: Eq<A>): {
  (xs: Array<A>): (ys: Array<A>) => Array<A>
  (xs: Array<A>, ys: Array<A>): Array<A>
}

Example 例子

import { union } from 'fp-ts/Array'
import * as N from 'fp-ts/number'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe([1, 2], union(N.Eq)([2, 3])), [1, 2, 3])

Added in v2.0.0 v2.0.0 中添加

uniq   独特的

Creates a new Array removing duplicate elements, keeping the first occurrence of an element, based on a Eq<A>.
基于 Eq<A> 创建一个新的 Array ,删除重复元素,保留元素的第一次出现。

Signature 签名

export declare const uniq: <A>(E: Eq<A>) => (as: A[]) => A[]

Example 例子

import { uniq } from 'fp-ts/Array'
import * as N from 'fp-ts/number'

assert.deepStrictEqual(uniq(N.Eq)([1, 2, 1]), [1, 2])

Added in v2.0.0 v2.0.0 中添加

unzip   解压

The function is reverse of zip. Takes an array of pairs and return two corresponding arrays
该功能与 zip 相反。获取一个pairs数组并返回两个对应的数组

Signature 签名

export declare const unzip: <A, B>(as: [A, B][]) => [A[], B[]]

Example 例子

import { unzip } from 'fp-ts/Array'

assert.deepStrictEqual(
  unzip([
    [1, 'a'],
    [2, 'b'],
    [3, 'c'],
  ]),
  [
    [1, 2, 3],
    ['a', 'b', 'c'],
  ]
)

Added in v2.0.0 v2.0.0 中添加

updateAt   更新时间

Change the element at the specified index, creating a new array, or returning None if the index is out of bounds.
更改指定索引处的元素,创建新数组,或者如果索引越界则返回 None

Signature 签名

export declare const updateAt: <A>(i: number, a: A) => (as: A[]) => Option<A[]>

Example 例子

import { updateAt } from 'fp-ts/Array'
import { some, none } from 'fp-ts/Option'

assert.deepStrictEqual(updateAt(1, 1)([1, 2, 3]), some([1, 1, 3]))
assert.deepStrictEqual(updateAt(1, 1)([]), none)

Added in v2.0.0 v2.0.0 中添加

zero  

Makes an empty Array, useful for building a Monoid
制作一个空的 Array ,对于构建 Monoid 很有用

Signature 签名

export declare const zero: <A>() => A[]

Added in v2.7.0 v2.7.0 中添加

zip   压缩

Takes two arrays and returns an array of corresponding pairs. If one input array is short, excess elements of the longer array are discarded
接受两个数组并返回对应对的数组。如果一个输入数组很短,则较长数组中多余的元素将被丢弃

Signature 签名

export declare function zip<B>(bs: Array<B>): <A>(as: Array<A>) => Array<[A, B]>
export declare function zip<A, B>(as: Array<A>, bs: Array<B>): Array<[A, B]>

Example 例子

import { zip } from 'fp-ts/Array'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe([1, 2, 3], zip(['a', 'b', 'c', 'd'])), [
  [1, 'a'],
  [2, 'b'],
  [3, 'c'],
])

Added in v2.0.0 v2.0.0 中添加

zipWith   zipWith

Apply a function to pairs of elements at the same index in two arrays, collecting the results in a new array. If one input array is short, excess elements of the longer array are discarded.
将函数应用于两个数组中相同索引处的元素对,并将结果收集到新数组中。如果一个输入数组很短,则较长数组中多余的元素将被丢弃。

Signature 签名

export declare const zipWith: <A, B, C>(fa: A[], fb: B[], f: (a: A, b: B) => C) => C[]

Example 例子

import { zipWith } from 'fp-ts/Array'

assert.deepStrictEqual(
  zipWith([1, 2, 3], ['a', 'b', 'c', 'd'], (n, s) => s + n),
  ['a1', 'b2', 'c3']
)

Added in v2.0.0 v2.0.0 中添加

zone of death
死亡地带

array 大批

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass A.Functor instead of A.array (where A is from import A from 'fp-ts/Array')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 A.Functor 而不是 A.array (其中 A 来自 import A from 'fp-ts/Array'

Signature 签名

export declare const array: FunctorWithIndex1<'Array', number> &
  Monad1<'Array'> &
  Unfoldable1<'Array'> &
  Alternative1<'Array'> &
  Extend1<'Array'> &
  FilterableWithIndex1<'Array', number> &
  FoldableWithIndex1<'Array', number> &
  TraversableWithIndex1<'Array', number> &
  Witherable1<'Array'>

Added in v2.0.0 v2.0.0 中添加

cons 缺点

Use prepend instead. 请改用 prepend

Signature 签名

export declare const cons: typeof NEA.cons

Added in v2.0.0 v2.0.0 中添加

empty 空的

Use a new [] instead.
请改用新的 []

Signature 签名

export declare const empty: never[]

Added in v2.0.0 v2.0.0 中添加

prependToAll 前置到全部

Use prependAll instead 使用 prependAll 代替

Signature 签名

export declare const prependToAll: <A>(middle: A) => (as: A[]) => A[]

Added in v2.9.0 v2.9.0中添加

range 范围

Use NonEmptyArray module instead. 请改用 NonEmptyArray 模块。

Signature 签名

export declare const range: (start: number, end: number) => NEA.NonEmptyArray<number>

Added in v2.0.0 v2.0.0 中添加

snoc 斯诺克

Use append instead. 请改用 append

Signature 签名

export declare const snoc: <A>(init: A[], end: A) => NEA.NonEmptyArray<A>

Added in v2.0.0 v2.0.0 中添加

Bifunctor overview  双函子概述

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Bifunctor (interface)   双函子(接口)

Signature 签名

export interface Bifunctor<F> {
  readonly URI: F
  readonly bimap: <E, A, G, B>(fea: HKT2<F, E, A>, f: (e: E) => G, g: (a: A) => B) => HKT2<F, G, B>
  readonly mapLeft: <E, A, G>(fea: HKT2<F, E, A>, f: (e: E) => G) => HKT2<F, G, A>
}

Added in v2.0.0 v2.0.0 中添加

Bifunctor2 (interface)   Bifunctor2(接口)

Signature 签名

export interface Bifunctor2<F extends URIS2> {
  readonly URI: F
  readonly bimap: <E, A, G, B>(fea: Kind2<F, E, A>, f: (e: E) => G, g: (a: A) => B) => Kind2<F, G, B>
  readonly mapLeft: <E, A, G>(fea: Kind2<F, E, A>, f: (e: E) => G) => Kind2<F, G, A>
}

Added in v2.0.0 v2.0.0 中添加

Bifunctor2C (interface)
Bifunctor2C(接口)

Signature 签名

export interface Bifunctor2C<F extends URIS2, E> {
  readonly URI: F
  readonly _E: E
  readonly bimap: <A, G, B>(fea: Kind2<F, E, A>, f: (e: E) => G, g: (a: A) => B) => Kind2<F, G, B>
  readonly mapLeft: <A, M>(fea: Kind2<F, E, A>, f: (e: E) => M) => Kind2<F, M, A>
}

Added in v2.0.0 v2.0.0 中添加

Bifunctor3 (interface)   Bifunctor3(接口)

Signature 签名

export interface Bifunctor3<F extends URIS3> {
  readonly URI: F
  readonly bimap: <R, E, A, G, B>(fea: Kind3<F, R, E, A>, f: (e: E) => G, g: (a: A) => B) => Kind3<F, R, G, B>
  readonly mapLeft: <R, E, A, G>(fea: Kind3<F, R, E, A>, f: (e: E) => G) => Kind3<F, R, G, A>
}

Added in v2.0.0 v2.0.0 中添加

Bifunctor3C (interface)
Bifunctor3C(接口)

Signature 签名

export interface Bifunctor3C<F extends URIS3, E> {
  readonly URI: F
  readonly _E: E
  readonly bimap: <R, A, G, B>(fea: Kind3<F, R, E, A>, f: (e: E) => G, g: (a: A) => B) => Kind3<F, R, G, B>
  readonly mapLeft: <R, A, G>(fea: Kind3<F, R, E, A>, f: (e: E) => G) => Kind3<F, R, G, A>
}

Added in v2.2.0 v2.2.0中添加

Bifunctor4 (interface)   Bifunctor4(接口)

Signature 签名

export interface Bifunctor4<F extends URIS4> {
  readonly URI: F
  readonly bimap: <S, R, E, A, G, B>(fea: Kind4<F, S, R, E, A>, f: (e: E) => G, g: (a: A) => B) => Kind4<F, S, R, G, B>
  readonly mapLeft: <S, R, E, A, G>(fea: Kind4<F, S, R, E, A>, f: (e: E) => G) => Kind4<F, S, R, G, A>
}

Added in v2.0.0 v2.0.0 中添加

boolean overview  布尔概述

Added in v2.2.0 v2.2.0中添加


Table of contents
目录


instances   实例

BooleanAlgebra   布尔代数

Signature 签名

export declare const BooleanAlgebra: BA.BooleanAlgebra<boolean>

Added in v2.10.0 v2.10.0 中添加

Eq   方程

Signature 签名

export declare const Eq: E.Eq<boolean>

Added in v2.10.0 v2.10.0 中添加

MonoidAll   幺半群

boolean monoid under conjunction.
boolean 联词下的幺半群。

The empty value is true.
empty 值为 true

Signature 签名

export declare const MonoidAll: Monoid<boolean>

Example 例子

import { MonoidAll } from 'fp-ts/boolean'

assert.deepStrictEqual(MonoidAll.concat(true, true), true)
assert.deepStrictEqual(MonoidAll.concat(true, false), false)

Added in v2.10.0 v2.10.0 中添加

MonoidAny  幺半群

boolean monoid under disjunction.
boolean 析取下的幺半群。

The empty value is false.
empty 值为 false

Signature 签名

export declare const MonoidAny: Monoid<boolean>

Example 例子

import { MonoidAny } from 'fp-ts/boolean'

assert.deepStrictEqual(MonoidAny.concat(true, true), true)
assert.deepStrictEqual(MonoidAny.concat(true, false), true)
assert.deepStrictEqual(MonoidAny.concat(false, false), false)

Added in v2.10.0 v2.10.0 中添加

Ord   奥德

Signature 签名

export declare const Ord: O.Ord<boolean>

Added in v2.10.0 v2.10.0 中添加

SemigroupAll   半群全部

boolean semigroup under conjunction.
boolean 合取下的半群。

Signature 签名

export declare const SemigroupAll: Semigroup<boolean>

Example 例子

import { SemigroupAll } from 'fp-ts/boolean'

assert.deepStrictEqual(SemigroupAll.concat(true, true), true)
assert.deepStrictEqual(SemigroupAll.concat(true, false), false)

Added in v2.10.0 v2.10.0 中添加

SemigroupAny   半群任意

boolean semigroup under disjunction.
boolean 析取半群。

Signature 签名

export declare const SemigroupAny: Semigroup<boolean>

Example 例子

import { SemigroupAny } from 'fp-ts/boolean'

assert.deepStrictEqual(SemigroupAny.concat(true, true), true)
assert.deepStrictEqual(SemigroupAny.concat(true, false), true)
assert.deepStrictEqual(SemigroupAny.concat(false, false), false)

Added in v2.10.0 v2.10.0 中添加

Show   展示

Signature 签名

export declare const Show: S.Show<boolean>

Added in v2.10.0 v2.10.0 中添加

pattern matching   模式匹配

fold   折叠

Alias of match.  match 的别名。

Signature 签名

export declare const fold: <A>(onFalse: LazyArg<A>, onTrue: LazyArg<A>) => (value: boolean) => A

Added in v2.2.0 v2.2.0中添加

foldW   折叠W

Alias of matchW.  matchW 的别名。

Signature 签名

export declare const foldW: <A, B>(onFalse: LazyArg<A>, onTrue: LazyArg<B>) => (value: boolean) => A | B

Added in v2.10.0 v2.10.0 中添加

match   匹配

Defines the fold over a boolean value. Takes two thunks onTrue, onFalse and a boolean value. If value is false, onFalse() is returned, otherwise onTrue().
定义布尔值的折叠。采用两个 thunk onTrueonFalse 和一个 boolean 值。如果 value 为假,则返回 onFalse() ,否则返回 onTrue()

Signature 签名

export declare const match: <A>(onFalse: LazyArg<A>, onTrue: LazyArg<A>) => (value: boolean) => A

Example 例子

import { some, map } from 'fp-ts/Option'
import { pipe } from 'fp-ts/function'
import { match } from 'fp-ts/boolean'

assert.deepStrictEqual(
  pipe(
    some(true),
    map(
      match(
        () => 'false',
        () => 'true'
      )
    )
  ),
  some('true')
)

Added in v2.10.0 v2.10.0 中添加

matchW   匹配W

Less strict version of match.
match 的不太严格版本。

The W suffix (short for Widening) means that the handler return types will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const matchW: <A, B>(onFalse: LazyArg<A>, onTrue: LazyArg<B>) => (value: boolean) => A | B

Added in v2.10.0 v2.10.0 中添加

refinements   改进

isBoolean   是布尔值

Signature 签名

export declare const isBoolean: Refinement<unknown, boolean>

Added in v2.11.0 v2.11.0 中添加

BooleanAlgebra overview
布尔代数概述

Boolean algebras are Heyting algebras with the additional constraint that the law of the excluded middle is true (equivalently, double-negation is true).
布尔代数是带有额外约束的 Heyting 代数,即排中律为真(等效地,双重否定为真)。

Instances should satisfy the following laws in addition to the HeytingAlgebra laws:
除了 HeytingAlgebra 定律外,实例还应满足以下定律:

  • Excluded middle: a ∨ ¬a <-> 1 排除中间: a ∨ ¬a <-> 1

Boolean algebras generalize classical logic: one is equivalent to “true” and zero is equivalent to “false”.
布尔代数概括了经典逻辑:1 相当于“真”,0 相当于“假”。

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


instances   实例

booleanAlgebraVoid   布尔代数空

Signature 签名

export declare const booleanAlgebraVoid: BooleanAlgebra<void>

Added in v2.0.0 v2.0.0 中添加

model   模型

BooleanAlgebra (interface)
布尔代数(接口)

Signature 签名

export interface BooleanAlgebra<A> extends HeytingAlgebra<A> {}

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

reverse   撤销

Every boolean algebras has a dual algebra, which involves reversing one/zero as well as join/meet.
每个布尔代数都有一个对偶代数,其中涉及反转一/零以及连接/相遇。

Signature 签名

export declare const reverse: <A>(B: BooleanAlgebra<A>) => BooleanAlgebra<A>

Added in v2.10.0 v2.10.0 中添加

zone of death
死亡地带

booleanAlgebraBoolean 布尔代数布尔

Use BooleanAlgebra instead. 请改用 BooleanAlgebra

Signature 签名

export declare const booleanAlgebraBoolean: BooleanAlgebra<boolean>

Added in v2.0.0 v2.0.0 中添加

getDualBooleanAlgebra 获取对偶布尔代数

Use reverse instead. 请改用 reverse

Signature 签名

export declare const getDualBooleanAlgebra: <A>(B: BooleanAlgebra<A>) => BooleanAlgebra<A>

Added in v2.0.0 v2.0.0 中添加

getFunctionBooleanAlgebra
getFunction布尔代数

Use getBooleanAlgebra instead. 请改用 getBooleanAlgebra

Signature 签名

export declare const getFunctionBooleanAlgebra: <B>(
  B: BooleanAlgebra<B>
) => <A = never>() => BooleanAlgebra<(a: A) => B>

Added in v2.0.0 v2.0.0 中添加

Bounded overview  有界概述

The Bounded type class represents totally ordered types that have an upper and lower boundary.
Bounded 类型类表示具有上限和下限的全序类型。

Instances should satisfy the following law in addition to the Ord laws:
除了 Ord 定律外,实例还应满足以下定律:

  • Bounded: bottom <= a <= top 有界: bottom <= a <= top

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Bounded (interface)  有界(界面)

Signature 签名

export interface Bounded<A> extends Ord<A> {
  readonly top: A
  readonly bottom: A
}

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

clamp   夹钳

Clamp a value between bottom and top values.
将值限制在底部值和顶部值之间。

Signature 签名

export declare const clamp: <A>(B: Bounded<A>) => (a: A) => A

Added in v2.12.0 v2.12.0 中添加

reverse   撤销

Reverses the Ord of a bound and swaps top and bottom values.
反转边界的顺序并交换顶部和底部值。

Signature 签名

export declare const reverse: <A>(B: Bounded<A>) => Bounded<A>

Added in v2.12.0 v2.12.0 中添加

zone of death
死亡地带

boundedNumber 有界数

Use Bounded instead. 请改用 Bounded

Signature 签名

export declare const boundedNumber: Bounded<number>

Added in v2.0.0 v2.0.0 中添加

BoundedDistributiveLattice overview
有界分布格概述

A BoundedDistributiveLattice is a lattice that is both bounded and distributive
BoundedDistributiveLattice 是一个有界且分布的格子

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


constructors  构造函数

getMinMaxBoundedDistributiveLattice
getMinMaxBoundedDistributiveLattice

Signature 签名

export declare function getMinMaxBoundedDistributiveLattice<A>(
  O: Ord<A>
): (min: A, max: A) => BoundedDistributiveLattice<A>

Added in v2.0.0 v2.0.0 中添加

model   模型

BoundedDistributiveLattice (interface)
有界分布格(接口)

Signature 签名

export interface BoundedDistributiveLattice<A> extends BoundedLattice<A>, DistributiveLattice<A> {}

Added in v2.0.0 v2.0.0 中添加

BoundedJoinSemilattice overview
BoundedJoinSemilattice 概述

A BoundedJoinSemilattice must satisfy the following laws in addition to JoinSemilattice laws:
除了 JoinSemilattice 法则之外, BoundedJoinSemilattice 还必须满足以下法则:

  • a ∨ 0 <-> a

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

BoundedJoinSemilattice (interface)
BoundedJoinSemilattice(接口)

Signature 签名

export interface BoundedJoinSemilattice<A> extends JoinSemilattice<A> {
  readonly zero: A
}

Added in v2.0.0 v2.0.0 中添加

BoundedLattice overview
有界格概述

A BoundedLattice must satisfy the following in addition to BoundedMeetSemilattice and BoundedJoinSemilattice laws:
除了 BoundedMeetSemilatticeBoundedJoinSemilattice 定律之外, BoundedLattice 还必须满足以下条件:

  • Absorption law for meet: a ∧ (a ∨ b) <-> a
    满足吸收定律: a ∧ (a ∨ b) <-> a
  • Absorption law for join: a ∨ (a ∧ b) <-> a
    join 的吸收定律: a ∨ (a ∧ b) <-> a

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

BoundedLattice (interface)
有界格子(接口)

Signature 签名

export interface BoundedLattice<A> extends BoundedJoinSemilattice<A>, BoundedMeetSemilattice<A> {}

Added in v2.0.0 v2.0.0 中添加

BoundedMeetSemilattice overview
BoundedMeetSemilattice 概述

A BoundedMeetSemilattice must satisfy the following laws in addition to MeetSemilattice laws:
除了 MeetSemilattice 法则之外, BoundedMeetSemilattice 还必须满足以下法则:

  • a ∧ 1 <-> a

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

BoundedMeetSemilattice (interface)
BoundedMeetSemilattice(接口)

Signature 签名

export interface BoundedMeetSemilattice<A> extends MeetSemilattice<A> {
  readonly one: A
}

Added in v2.0.0 v2.0.0 中添加

Category overview  品类概览

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Category (interface)   类别(接口)

Signature 签名

export interface Category<F> extends Semigroupoid<F> {
  readonly id: <A>() => HKT2<F, A, A>
}

Added in v2.0.0 v2.0.0 中添加

Category2 (interface)   类别2(接口)

Signature 签名

export interface Category2<F extends URIS2> extends Semigroupoid2<F> {
  readonly id: <A>() => Kind2<F, A, A>
}

Added in v2.0.0 v2.0.0 中添加

Category3 (interface)   Category3(接口)

Signature 签名

export interface Category3<F extends URIS3> extends Semigroupoid3<F> {
  readonly id: <R, A>() => Kind3<F, R, A, A>
}

Added in v2.0.0 v2.0.0 中添加

Category4 (interface)   Category4(接口)

Signature 签名

export interface Category4<F extends URIS4> extends Semigroupoid4<F> {
  readonly id: <S, R, A>() => Kind4<F, S, R, A, A>
}

Added in v2.0.0 v2.0.0 中添加

Chain overview  链条概览

The Chain type class extends the Apply type class with a chain operation which composes computations in sequence, using the return value of one computation to determine the next computation.
Chain 类型类使用 chain 操作扩展了 Apply 类型类,chain 操作按顺序组成计算,使用一个计算的返回值来确定下一个计算。

Instances must satisfy the following law in addition to the Apply laws:
除了 Apply 法则之外,实例还必须满足以下法则:

  1. Associativity: F.chain(F.chain(fa, afb), bfc) <-> F.chain(fa, a => F.chain(afb(a), bfc)) 关联性: F.chain(F.chain(fa, afb), bfc) <-> F.chain(fa, a => F.chain(afb(a), bfc))

Note. Apply’s ap can be derived: (fab, fa) => F.chain(fab, f => F.map(fa, f))
笔记。 Apply 的@​​1#可以推导出: (fab, fa) => F.chain(fab, f => F.map(fa, f))

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Chain (interface)   链条(接口)

Signature 签名

export interface Chain<F> extends Apply<F> {
  readonly chain: <A, B>(fa: HKT<F, A>, f: (a: A) => HKT<F, B>) => HKT<F, B>
}

Added in v2.0.0 v2.0.0 中添加

Chain1 (interface)   链1(接口)

Signature 签名

export interface Chain1<F extends URIS> extends Apply1<F> {
  readonly chain: <A, B>(fa: Kind<F, A>, f: (a: A) => Kind<F, B>) => Kind<F, B>
}

Added in v2.0.0 v2.0.0 中添加

Chain2 (interface)   链2(接口)

Signature 签名

export interface Chain2<F extends URIS2> extends Apply2<F> {
  readonly chain: <E, A, B>(fa: Kind2<F, E, A>, f: (a: A) => Kind2<F, E, B>) => Kind2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

Chain2C (interface)   Chain2C(接口)

Signature 签名

export interface Chain2C<F extends URIS2, E> extends Apply2C<F, E> {
  readonly chain: <A, B>(fa: Kind2<F, E, A>, f: (a: A) => Kind2<F, E, B>) => Kind2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

Chain3 (interface)   链3(接口)

Signature 签名

export interface Chain3<F extends URIS3> extends Apply3<F> {
  readonly chain: <R, E, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => Kind3<F, R, E, B>) => Kind3<F, R, E, B>
}

Added in v2.0.0 v2.0.0 中添加

Chain3C (interface)   Chain3C(接口)

Signature 签名

export interface Chain3C<F extends URIS3, E> extends Apply3C<F, E> {
  readonly chain: <R, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => Kind3<F, R, E, B>) => Kind3<F, R, E, B>
}

Added in v2.2.0 v2.2.0中添加

Chain4 (interface)   链4(接口)

Signature 签名

export interface Chain4<F extends URIS4> extends Apply4<F> {
  readonly chain: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, f: (a: A) => Kind4<F, S, R, E, B>) => Kind4<F, S, R, E, B>
}

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

bind   绑定

Signature 签名

export declare function bind<M extends URIS4>(
  M: Chain4<M>
): <N extends string, A, S, R, E, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => Kind4<M, S, R, E, B>
) => (ma: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>
export declare function bind<M extends URIS3>(
  M: Chain3<M>
): <N extends string, A, R, E, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => Kind3<M, R, E, B>
) => (ma: Kind3<M, R, E, A>) => Kind3<M, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>
export declare function bind<M extends URIS3, E>(
  M: Chain3C<M, E>
): <N extends string, A, R, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => Kind3<M, R, E, B>
) => (ma: Kind3<M, R, E, A>) => Kind3<M, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>
export declare function bind<M extends URIS2>(
  M: Chain2<M>
): <N extends string, A, E, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => Kind2<M, E, B>
) => (ma: Kind2<M, E, A>) => Kind2<M, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>
export declare function bind<M extends URIS2, E>(
  M: Chain2C<M, E>
): <N extends string, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => Kind2<M, E, B>
) => (ma: Kind2<M, E, A>) => Kind2<M, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>
export declare function bind<M extends URIS>(
  M: Chain1<M>
): <N extends string, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => Kind<M, B>
) => (ma: Kind<M, A>) => Kind<M, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>
export declare function bind<M>(
  M: Chain<M>
): <N extends string, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => HKT<M, B>
) => (ma: HKT<M, A>) => HKT<M, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>

Added in v2.10.0 v2.10.0 中添加

chainFirst   链优先

Signature 签名

export declare function chainFirst<M extends URIS4>(
  M: Chain4<M>
): <A, S, R, E, _>(f: (a: A) => Kind4<M, S, R, E, _>) => (first: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, A>
export declare function chainFirst<M extends URIS3>(
  M: Chain3<M>
): <A, R, E, _>(f: (a: A) => Kind3<M, R, E, _>) => (first: Kind3<M, R, E, A>) => Kind3<M, R, E, A>
export declare function chainFirst<M extends URIS3, E>(
  M: Chain3C<M, E>
): <A, R, _>(f: (a: A) => Kind3<M, R, E, _>) => (first: Kind3<M, R, E, A>) => Kind3<M, R, E, A>
export declare function chainFirst<M extends URIS2>(
  M: Chain2<M>
): <A, E, _>(f: (a: A) => Kind2<M, E, _>) => (first: Kind2<M, E, A>) => Kind2<M, E, A>
export declare function chainFirst<M extends URIS2, E>(
  M: Chain2C<M, E>
): <A, _>(f: (a: A) => Kind2<M, E, _>) => (first: Kind2<M, E, A>) => Kind2<M, E, A>
export declare function chainFirst<M extends URIS>(
  M: Chain1<M>
): <A, _>(f: (a: A) => Kind<M, _>) => (first: Kind<M, A>) => Kind<M, A>
export declare function chainFirst<M>(M: Chain<M>): <A, _>(f: (a: A) => HKT<M, _>) => (first: HKT<M, A>) => HKT<M, A>

Added in v2.10.0 v2.10.0 中添加

ChainRec overview  ChainRec 概述

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

ChainRec (interface)   ChainRec(接口)

Signature 签名

export interface ChainRec<F> extends Chain<F> {
  readonly chainRec: <A, B>(a: A, f: (a: A) => HKT<F, Either<A, B>>) => HKT<F, B>
}

Added in v2.0.0 v2.0.0 中添加

ChainRec1 (interface)   ChainRec1(接口)

Signature 签名

export interface ChainRec1<F extends URIS> extends Chain1<F> {
  readonly chainRec: <A, B>(a: A, f: (a: A) => Kind<F, Either<A, B>>) => Kind<F, B>
}

Added in v2.0.0 v2.0.0 中添加

ChainRec2 (interface)   ChainRec2(接口)

Signature 签名

export interface ChainRec2<F extends URIS2> extends Chain2<F> {
  readonly chainRec: <E, A, B>(a: A, f: (a: A) => Kind2<F, E, Either<A, B>>) => Kind2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

ChainRec2C (interface)   ChainRec2C(接口)

Signature 签名

export interface ChainRec2C<F extends URIS2, E> extends Chain2C<F, E> {
  readonly chainRec: <A, B>(a: A, f: (a: A) => Kind2<F, E, Either<A, B>>) => Kind2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

ChainRec3 (interface)   ChainRec3(接口)

Signature 签名

export interface ChainRec3<F extends URIS3> extends Chain3<F> {
  readonly chainRec: <R, E, A, B>(a: A, f: (a: A) => Kind3<F, R, E, Either<A, B>>) => Kind3<F, R, E, B>
}

Added in v2.0.0 v2.0.0 中添加

ChainRec3C (interface)   ChainRec3C(接口)

Signature 签名

export interface ChainRec3C<F extends URIS3, E> extends Chain3C<F, E> {
  readonly chainRec: <R, A, B>(a: A, f: (a: A) => Kind3<F, R, E, Either<A, B>>) => Kind3<F, R, E, B>
}

Added in v2.10.0 v2.10.0 中添加

ChainRec4 (interface)   ChainRec4(接口)

Signature 签名

export interface ChainRec4<F extends URIS4> extends Chain4<F> {
  readonly chainRec: <S, R, E, A, B>(a: A, f: (a: A) => Kind4<F, S, R, E, Either<A, B>>) => Kind4<F, S, R, E, B>
}

Added in v2.10.0 v2.10.0 中添加

utils   实用程序

tailRec   尾部记录

Signature 签名

export declare const tailRec: <A, B>(startWith: A, f: (a: A) => Either<A, B>) => B

Added in v2.0.0 v2.0.0 中添加

Choice overview  选择概览

The Choice class extends Profunctor with combinators for working with sum types.
Choice 类使用组合器扩展了 Profunctor ,以处理求和类型。

left and right lift values in a Profunctor to act on the Left and Right components of a sum, respectively.
leftright 提升 Profunctor 中的值,分别作用于总和的 LeftRight 部分。

Looking at Choice through the intuition of inputs and outputs yields the following type signature:
通过输入和输出的直觉查看 Choice 会产生以下类型签名:

left ::  forall input output a. p input output -> p (Either input a) (Either output a)
right :: forall input output a. p input output -> p (Either a input) (Either a output)

If we specialize the profunctor p to the function arrow, we get the following type signatures:
如果我们将表示符 p 专门化为 function 箭头,我们会得到以下类型签名:

left ::  forall input output a. (input -> output) -> (Either input a) -> (Either output a)
right :: forall input output a. (input -> output) -> (Either a input) -> (Either a output)

When the profunctor is Function application, left allows you to map a function over the left side of an Either, and right maps it over the right side (same as map would do).
profunctorFunction 应用程序时, left 允许您将函数映射到 Either 的左侧, right 将其映射到右侧(与 map 相同)。

Adapted from https://github.com/purescript/purescript-profunctor/blob/master/src/Data/Profunctor/Choice.purs
改编自https://github.com/purescript/purescript-profunctor/blob/master/src/Data/Profunctor/Choice.purs

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Choice (interface)   选择(界面)

Signature 签名

export interface Choice<F> extends Profunctor<F> {
  readonly left: <A, B, C>(pab: HKT2<F, A, B>) => HKT2<F, Either<A, C>, Either<B, C>>
  readonly right: <A, B, C>(pbc: HKT2<F, B, C>) => HKT2<F, Either<A, B>, Either<A, C>>
}

Added in v2.0.0 v2.0.0 中添加

Choice2 (interface)   选择2(界面)

Signature 签名

export interface Choice2<F extends URIS2> extends Profunctor2<F> {
  readonly left: <A, B, C>(pab: Kind2<F, A, B>) => Kind2<F, Either<A, C>, Either<B, C>>
  readonly right: <A, B, C>(pbc: Kind2<F, B, C>) => Kind2<F, Either<A, B>, Either<A, C>>
}

Added in v2.0.0 v2.0.0 中添加

Choice3 (interface)   选择3(界面)

Signature 签名

export interface Choice3<F extends URIS3> extends Profunctor3<F> {
  readonly left: <R, A, B, C>(pab: Kind3<F, R, A, B>) => Kind3<F, R, Either<A, C>, Either<B, C>>
  readonly right: <R, A, B, C>(pbc: Kind3<F, R, B, C>) => Kind3<F, R, Either<A, B>, Either<A, C>>
}

Added in v2.0.0 v2.0.0 中添加

Choice4 (interface)   选择4(界面)

Signature 签名

export interface Choice4<F extends URIS4> extends Profunctor4<F> {
  readonly left: <S, R, A, B, C>(pab: Kind4<F, S, R, A, B>) => Kind4<F, S, R, Either<A, C>, Either<B, C>>
  readonly right: <S, R, A, B, C>(pbc: Kind4<F, S, R, B, C>) => Kind4<F, S, R, Either<A, B>, Either<A, C>>
}

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

fanIn   扇入

Compose a value which eliminates a sum from two values, each eliminating one side of the sum.
组成一个值,从两个值中减去总和,每个值都消除总和的一侧。

This combinator is useful when assembling values from smaller components, because it provides a way to support two different types of input.
当从较小的组件组​​装值时,此组合器非常有用,因为它提供了一种支持两种不同类型输入的方法。

Specializing fanIn to function application would look like this:
fanIn 专门化为函数应用程序将如下所示:

fanIn :: forall a b c d. (a -> c) -> (b -> c) -> Either a b -> c

We take two functions, f and g, which both return the same type c and we transform them into a single function which takes an Either value with the parameter type of f on the left side and the parameter type of g on the right side. The function then runs either f or g, depending on whether the Either value is a Left or a Right. This allows us to bundle two different computations which both have the same result type into one function which will run the appropriate computation based on the parameter supplied in the Either value.
我们采用两个函数 fg ,它们都返回相同类型的 c ,我们将它们转换为单个函数,该函数采用 Either 值,左侧参数类型为 f ,右侧 g 的参数类型。然后,该函数运行 fg ,具体取决于 Either 值是 Left 还是 Right 。这允许我们将两个具有相同结果类型的不同计算捆绑到一个函数中,该函数将根据 Either 值中提供的参数运行适当的计算。

Signature 签名

export declare function fanIn<P extends URIS4>(
  P: Choice4<P>,
  C: Category4<P>
): <S, R, A, B, C>(pac: Kind4<P, S, R, A, C>, pbc: Kind4<P, S, R, B, C>) => Kind4<P, S, R, Either<A, B>, C>
export declare function fanIn<P extends URIS3>(
  P: Choice3<P>,
  C: Category3<P>
): <R, A, B, C>(pac: Kind3<P, R, A, C>, pbc: Kind3<P, R, B, C>) => Kind3<P, R, Either<A, B>, C>
export declare function fanIn<P extends URIS2>(
  P: Choice2<P>,
  C: Category2<P>
): <A, B, C>(pac: Kind2<P, A, C>, pbc: Kind2<P, B, C>) => Kind2<P, Either<A, B>, C>
export declare function fanIn<P>(
  P: Choice<P>,
  C: Category<P>
): <A, B, C>(pac: HKT2<P, A, C>, pbc: HKT2<P, B, C>) => HKT2<P, Either<A, B>, C>

Added in v2.10.0 v2.10.0 中添加

split   分裂

Compose a value acting on a sum from two values, each acting on one of the components of the sum.
由两个值组成一个作用于总和的值,每个值作用于总和的一个分量。

Specializing split to function application would look like this:
split 专门化为函数应用程序将如下所示:

split :: forall a b c d. (a -> b) -> (c -> d) -> (Either a c) -> (Either b d)

We take two functions, f and g, and we transform them into a single function which takes an Eitherand maps f over the left side and g over the right side. Just like bimap would do for the Bifunctor instance of Either.
我们采用两个函数 fg ,并将它们转换为一个函数,该函数采用 Either 并将 f 映射到左侧,将 g 映射到右侧。就像 bimapEitherBifunctor 实例所做的那样。

Signature 签名

export declare function split<P extends URIS4>(
  P: Choice4<P>,
  C: Category4<P>
): <S, R, A, B, C, D>(
  pab: Kind4<P, S, R, A, B>,
  pcd: Kind4<P, S, R, C, D>
) => Kind4<P, S, R, Either<A, C>, Either<B, D>>
export declare function split<P extends URIS3>(
  P: Choice3<P>,
  C: Category3<P>
): <R, A, B, C, D>(pab: Kind3<P, R, A, B>, pcd: Kind3<P, R, C, D>) => Kind3<P, R, Either<A, C>, Either<B, D>>
export declare function split<P extends URIS2>(
  P: Choice2<P>,
  C: Category2<P>
): <A, B, C, D>(pab: Kind2<P, A, B>, pcd: Kind2<P, C, D>) => Kind2<P, Either<A, C>, Either<B, D>>
export declare function split<P>(
  P: Choice<P>,
  C: Category<P>
): <A, B, C, D>(pab: HKT2<P, A, B>, pcd: HKT2<P, C, D>) => HKT2<P, Either<A, C>, Either<B, D>>

Added in v2.10.0 v2.10.0 中添加

fanin 范宁

Use fanIn instead. 请改用 fanIn

Signature 签名

export declare function fanin<F extends URIS3>(
  F: Category3<F> & Choice3<F>
): <R, A, B, C>(pac: Kind3<F, R, A, C>, pbc: Kind3<F, R, B, C>) => Kind3<F, R, Either<A, B>, C>
export declare function fanin<F extends URIS2>(
  F: Category2<F> & Choice2<F>
): <A, B, C>(pac: Kind2<F, A, C>, pbc: Kind2<F, B, C>) => Kind2<F, Either<A, B>, C>
export declare function fanin<F>(
  F: Category<F> & Choice<F>
): <A, B, C>(pac: HKT2<F, A, C>, pbc: HKT2<F, B, C>) => HKT2<F, Either<A, B>, C>

Added in v2.0.0 v2.0.0 中添加

zone of death
死亡地带

splitChoice 分裂选择

Use split instead. 请改用 split

Signature 签名

export declare function splitChoice<F extends URIS3>(
  F: Category3<F> & Choice3<F>
): <R, A, B, C, D>(pab: Kind3<F, R, A, B>, pcd: Kind3<F, R, C, D>) => Kind3<F, R, Either<A, C>, Either<B, D>>
export declare function splitChoice<F extends URIS2>(
  F: Category2<F> & Choice2<F>
): <A, B, C, D>(pab: Kind2<F, A, B>, pcd: Kind2<F, C, D>) => Kind2<F, Either<A, C>, Either<B, D>>
export declare function splitChoice<F>(
  F: Category<F> & Choice<F>
): <A, B, C, D>(pab: HKT2<F, A, B>, pcd: HKT2<F, C, D>) => HKT2<F, Either<A, C>, Either<B, D>>

Added in v2.0.0 v2.0.0 中添加

Comonad overview  Comonad 概述

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Comonad (interface)   科莫纳德(接口)

Signature 签名

export interface Comonad<W> extends Extend<W> {
  readonly extract: <A>(wa: HKT<W, A>) => A
}

Added in v2.0.0 v2.0.0 中添加

Comonad1 (interface)   Comonad1(接口)

Signature 签名

export interface Comonad1<W extends URIS> extends Extend1<W> {
  readonly extract: <A>(wa: Kind<W, A>) => A
}

Added in v2.0.0 v2.0.0 中添加

Comonad2 (interface)   Comonad2(接口)

Signature 签名

export interface Comonad2<W extends URIS2> extends Extend2<W> {
  readonly extract: <E, A>(wa: Kind2<W, E, A>) => A
}

Added in v2.0.0 v2.0.0 中添加

Comonad2C (interface)   Comonad2C(接口)

Signature 签名

export interface Comonad2C<W extends URIS2, E> extends Extend2C<W, E> {
  readonly extract: <A>(wa: Kind2<W, E, A>) => A
}

Added in v2.0.0 v2.0.0 中添加

Comonad3 (interface)   Comonad3(接口)

Signature 签名

export interface Comonad3<W extends URIS3> extends Extend3<W> {
  readonly extract: <R, E, A>(wa: Kind3<W, R, E, A>) => A
}

Added in v2.0.0 v2.0.0 中添加

Comonad3C (interface)   Comonad3C(接口)

Signature 签名

export interface Comonad3C<W extends URIS3, E> extends Extend3C<W, E> {
  readonly extract: <R, A>(wa: Kind3<W, R, E, A>) => A
}

Added in v2.10.0 v2.10.0 中添加

Comonad4 (interface)   Comonad4(接口)

Signature 签名

export interface Comonad4<W extends URIS4> extends Extend4<W> {
  readonly extract: <S, R, E, A>(wa: Kind4<W, S, R, E, A>) => A
}

Added in v2.10.0 v2.10.0 中添加

Compactable overview  紧凑概述

Compactable represents data structures which can be compacted/filtered. This is a generalization of catOptions as a new function compact. compact has relations with Functor, Applicative, Monad, Alternative, and Traversable in that we can use these classes to provide the ability to operate on a data type by eliminating intermediate Nones. This is useful for representing the filtering out of values, or failure.
Compactable 表示可以压缩/过滤的数据结构。这是 catOptions 作为新函数 compact 的概括。 compactFunctorApplicativeMonadAlternativeTraversable 有关系,因为我们可以使用这些类通过消除中间的 None 来提供对数据类型进行操作的能力。这对于表示过滤掉值或失败非常有用。

Adapted from https://github.com/LiamGoodacre/purescript-filterable/blob/master/src/Data/Compactable.purs
改编自https://github.com/LiamGoodacre/purescript-filterable/blob/master/src/Data/Compactable.purs

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Compactable (interface)
可紧凑(界面)

Signature 签名

export interface Compactable<F> {
  readonly URI: F
  /**
   * Compacts a data structure unwrapping inner Option
   */
  readonly compact: <A>(fa: HKT<F, Option<A>>) => HKT<F, A>
  /**
   * Separates a data structure moving inner Left to the left side and inner Right to the right side of Separated
   */
  readonly separate: <A, B>(fa: HKT<F, Either<A, B>>) => S.Separated<HKT<F, A>, HKT<F, B>>
}

Added in v2.0.0 v2.0.0 中添加

Compactable1 (interface)
可压缩1(接口)

Signature 签名

export interface Compactable1<F extends URIS> {
  readonly URI: F
  readonly compact: <A>(fa: Kind<F, Option<A>>) => Kind<F, A>
  readonly separate: <A, B>(fa: Kind<F, Either<A, B>>) => S.Separated<Kind<F, A>, Kind<F, B>>
}

Added in v2.0.0 v2.0.0 中添加

Compactable2 (interface)
可压缩2(接口)

Signature 签名

export interface Compactable2<F extends URIS2> {
  readonly URI: F
  readonly compact: <E, A>(fa: Kind2<F, E, Option<A>>) => Kind2<F, E, A>
  readonly separate: <E, A, B>(fa: Kind2<F, E, Either<A, B>>) => S.Separated<Kind2<F, E, A>, Kind2<F, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

Compactable2C (interface)
Compactable2C(接口)

Signature 签名

export interface Compactable2C<F extends URIS2, E> {
  readonly URI: F
  readonly _E: E
  readonly compact: <A>(fa: Kind2<F, E, Option<A>>) => Kind2<F, E, A>
  readonly separate: <A, B>(fa: Kind2<F, E, Either<A, B>>) => S.Separated<Kind2<F, E, A>, Kind2<F, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

Compactable3 (interface)
紧凑3(接口)

Signature 签名

export interface Compactable3<F extends URIS3> {
  readonly URI: F
  readonly compact: <R, E, A>(fa: Kind3<F, R, E, Option<A>>) => Kind3<F, R, E, A>
  readonly separate: <R, E, A, B>(fa: Kind3<F, R, E, Either<A, B>>) => S.Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

Compactable3C (interface)
Compactable3C(接口)

Signature 签名

export interface Compactable3C<F extends URIS3, E> {
  readonly URI: F
  readonly _E: E
  readonly compact: <R, A>(fa: Kind3<F, R, E, Option<A>>) => Kind3<F, R, E, A>
  readonly separate: <R, A, B>(fa: Kind3<F, R, E, Either<A, B>>) => S.Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>
}

Added in v2.2.0 v2.2.0中添加

Compactable4 (interface)
可压缩4(接口)

Signature 签名

export interface Compactable4<F extends URIS4> {
  readonly URI: F
  readonly compact: <S, R, E, A>(fa: Kind4<F, S, R, E, Option<A>>) => Kind4<F, S, R, E, A>
  readonly separate: <S, R, E, A, B>(
    fa: Kind4<F, S, R, E, Either<A, B>>
  ) => S.Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

compact   袖珍的

compact composition.

Signature 签名

export declare function compact<F extends URIS2, G extends URIS2, E>(
  F: Functor2<F>,
  G: Compactable2C<G, E>
): <FE, A>(fa: Kind2<F, FE, Kind2<G, E, Option<A>>>) => Kind2<F, FE, Kind2<G, E, A>>
export declare function compact<F extends URIS, G extends URIS2, E>(
  F: Functor1<F>,
  G: Compactable2C<G, E>
): <A>(fa: Kind<F, Kind2<G, E, Option<A>>>) => Kind<F, Kind2<G, E, A>>
export declare function compact<F extends URIS, G extends URIS>(
  F: Functor1<F>,
  G: Compactable1<G>
): <A>(fa: Kind<F, Kind<G, Option<A>>>) => Kind<F, Kind<G, A>>
export declare function compact<F, G>(
  F: Functor<F>,
  G: Compactable<G>
): <A>(fa: HKT<F, HKT<G, Option<A>>>) => HKT<F, HKT<G, A>>

Added in v2.10.0 v2.10.0 中添加

separate   分离

separate composition.

Signature 签名

export declare function separate<F extends URIS2, G extends URIS2, E>(
  F: Functor2<F>,
  C: Compactable2C<G, E>,
  G: Functor2<G>
): <FE, A, B>(
  fge: Kind2<F, FE, Kind2<G, E, Either<A, B>>>
) => S.Separated<Kind2<F, FE, Kind2<G, E, A>>, Kind2<F, FE, Kind2<G, E, B>>>
export declare function separate<F extends URIS, G extends URIS2, E>(
  F: Functor1<F>,
  C: Compactable2C<G, E>,
  G: Functor2<G>
): <A, B>(fge: Kind<F, Kind2<G, E, Either<A, B>>>) => S.Separated<Kind<F, Kind2<G, E, A>>, Kind<F, Kind2<G, E, B>>>
export declare function separate<F extends URIS, G extends URIS>(
  F: Functor1<F>,
  C: Compactable1<G>,
  G: Functor1<G>
): <A, B>(fge: Kind<F, Kind<G, Either<A, B>>>) => S.Separated<Kind<F, Kind<G, A>>, Kind<F, Kind<G, B>>>
export declare function separate<F, G>(
  F: Functor<F>,
  C: Compactable<G>,
  G: Functor<G>
): <A, B>(fge: HKT<F, HKT<G, Either<A, B>>>) => S.Separated<HKT<F, HKT<G, A>>, HKT<F, HKT<G, B>>>

Added in v2.10.0 v2.10.0 中添加

Separated 分开 (interface)   (界面)

Use Separated instead. 请改用 Separated

Signature 签名

export interface Separated<A, B> {
  readonly left: A
  readonly right: B
}

Added in v2.0.0 v2.0.0 中添加

zone of death
死亡地带

CompactableComposition11
可压缩组合物11
(interface)   (界面)

Signature 签名

export interface CompactableComposition11<F extends URIS, G extends URIS> extends FunctorComposition11<F, G> {
  readonly compact: <A>(fga: Kind<F, Kind<G, Option<A>>>) => Kind<F, Kind<G, A>>
  readonly separate: <A, B>(fge: Kind<F, Kind<G, Either<A, B>>>) => Separated<Kind<F, Kind<G, A>>, Kind<F, Kind<G, B>>>
}

Added in v2.0.0 v2.0.0 中添加

CompactableComposition12C
可压缩组合物12C
(interface)   (界面)

Signature 签名

export interface CompactableComposition12C<F extends URIS, G extends URIS2, E> extends FunctorComposition12C<F, G, E> {
  readonly compact: <A>(fga: Kind<F, Kind2<G, E, Option<A>>>) => Kind<F, Kind2<G, E, A>>
  readonly separate: <A, B>(
    fge: Kind<F, Kind2<G, E, Either<A, B>>>
  ) => Separated<Kind<F, Kind2<G, E, A>>, Kind<F, Kind2<G, E, B>>>
}

Added in v2.0.0 v2.0.0 中添加

CompactableComposition12
可压缩组合物12
(interface)   (界面)

Signature 签名

export interface CompactableComposition12<F extends URIS, G extends URIS2> extends FunctorComposition12<F, G> {
  readonly compact: <E, A>(fga: Kind<F, Kind2<G, E, Option<A>>>) => Kind<F, Kind2<G, E, A>>
  readonly separate: <E, A, B>(
    fge: Kind<F, Kind2<G, E, Either<A, B>>>
  ) => Separated<Kind<F, Kind2<G, E, A>>, Kind<F, Kind2<G, E, B>>>
}

Added in v2.0.0 v2.0.0 中添加

CompactableComposition21
可压缩组合物21
(interface)   (界面)

Signature 签名

export interface CompactableComposition21<F extends URIS2, G extends URIS> extends FunctorComposition21<F, G> {
  readonly compact: <FE, A>(fga: Kind2<F, FE, Kind<G, Option<A>>>) => Kind2<F, FE, Kind<G, A>>
  readonly separate: <FE, A, B>(
    fge: Kind2<F, FE, Kind<G, Either<A, B>>>
  ) => Separated<Kind2<F, FE, Kind<G, A>>, Kind2<F, FE, Kind<G, B>>>
}

Added in v2.0.0 v2.0.0 中添加

CompactableComposition22C
可压缩组合物22C
(interface)   (界面)

Signature 签名

export interface CompactableComposition22C<F extends URIS2, G extends URIS2, E> extends FunctorComposition22C<F, G, E> {
  readonly compact: <FE, A>(fga: Kind2<F, FE, Kind2<G, E, Option<A>>>) => Kind2<F, FE, Kind2<G, E, A>>
  readonly separate: <FE, A, B>(
    fge: Kind2<F, FE, Kind2<G, E, Either<A, B>>>
  ) => Separated<Kind2<F, FE, Kind2<G, E, A>>, Kind2<F, FE, Kind2<G, E, B>>>
}

Added in v2.0.0 v2.0.0 中添加

CompactableComposition22
可压缩组合物22
(interface)   (界面)

Signature 签名

export interface CompactableComposition22<F extends URIS2, G extends URIS2> extends FunctorComposition22<F, G> {
  readonly compact: <FE, GE, A>(fga: Kind2<F, FE, Kind2<G, GE, Option<A>>>) => Kind2<F, FE, Kind2<G, GE, A>>
  readonly separate: <FE, GE, A, B>(
    fge: Kind2<F, FE, Kind2<G, GE, Either<A, B>>>
  ) => Separated<Kind2<F, FE, Kind2<G, GE, A>>, Kind2<F, FE, Kind2<G, GE, B>>>
}

Added in v2.0.0 v2.0.0 中添加

CompactableComposition23C
可压缩组合物23C
(interface)   (界面)

Signature 签名

export interface CompactableComposition23C<F extends URIS2, G extends URIS3, E> extends FunctorComposition23C<F, G, E> {
  readonly compact: <FE, R, A>(fga: Kind2<F, FE, Kind3<G, R, E, Option<A>>>) => Kind2<F, FE, Kind3<G, R, E, A>>
  readonly separate: <FE, R, A, B>(
    fge: Kind2<F, FE, Kind3<G, R, E, Either<A, B>>>
  ) => Separated<Kind2<F, FE, Kind3<G, R, E, A>>, Kind2<F, FE, Kind3<G, R, E, B>>>
}

Added in v2.2.0 v2.2.0中添加

CompactableComposition23
可压缩组合物23
(interface)   (界面)

Signature 签名

export interface CompactableComposition23<F extends URIS2, G extends URIS3> extends FunctorComposition23<F, G> {
  readonly compact: <R, FE, GE, A>(fga: Kind2<F, FE, Kind3<G, R, GE, Option<A>>>) => Kind2<F, FE, Kind3<G, R, GE, A>>
  readonly separate: <R, FE, GE, A, B>(
    fge: Kind2<F, FE, Kind3<G, R, GE, Either<A, B>>>
  ) => Separated<Kind2<F, FE, Kind3<G, R, GE, A>>, Kind2<F, FE, Kind3<G, R, GE, B>>>
}

Added in v2.2.0 v2.2.0中添加

CompactableComposition2C1
可压缩组合物2C1
(interface)   (界面)

Signature 签名

export interface CompactableComposition2C1<F extends URIS2, G extends URIS, E> extends FunctorComposition2C1<F, G, E> {
  readonly compact: <A>(fga: Kind2<F, E, Kind<G, Option<A>>>) => Kind2<F, E, Kind<G, A>>
  readonly separate: <A, B>(
    fge: Kind2<F, E, Kind<G, Either<A, B>>>
  ) => Separated<Kind2<F, E, Kind<G, A>>, Kind2<F, E, Kind<G, B>>>
}

Added in v2.0.0 v2.0.0 中添加

CompactableComposition 压实组合物 (interface)   (界面)

Signature 签名

export interface CompactableComposition<F, G> extends FunctorComposition<F, G> {
  readonly compact: <A>(fga: HKT<F, HKT<G, Option<A>>>) => HKT<F, HKT<G, A>>
  readonly separate: <A, B>(fge: HKT<F, HKT<G, Either<A, B>>>) => Separated<HKT<F, HKT<G, A>>, HKT<F, HKT<G, B>>>
}

Added in v2.0.0 v2.0.0 中添加

getCompactableComposition
获取可压缩组合

Use compact and separate instead.
请改用 compactseparate

Signature 签名

export declare function getCompactableComposition<F extends URIS2, G extends URIS3, E>(
  F: Functor2<F>,
  G: Compactable3C<G, E> & Functor3C<G, E>
): CompactableComposition23C<F, G, E>
export declare function getCompactableComposition<F extends URIS2, G extends URIS2, E>(
  F: Functor2<F>,
  G: Compactable2C<G, E> & Functor2C<G, E>
): CompactableComposition22C<F, G, E>
export declare function getCompactableComposition<F extends URIS2, G extends URIS2>(
  F: Functor2<F>,
  G: Compactable2<G> & Functor2<G>
): CompactableComposition22<F, G>
export declare function getCompactableComposition<F extends URIS2, G extends URIS, E>(
  F: Functor2C<F, E>,
  G: Compactable1<G> & Functor1<G>
): CompactableComposition2C1<F, G, E>
export declare function getCompactableComposition<F extends URIS2, G extends URIS>(
  F: Functor2<F>,
  G: Compactable1<G> & Functor1<G>
): CompactableComposition21<F, G>
export declare function getCompactableComposition<F extends URIS, G extends URIS2, E>(
  F: Functor1<F>,
  G: Compactable2C<G, E> & Functor2C<G, E>
): CompactableComposition12<F, G>
export declare function getCompactableComposition<F extends URIS, G extends URIS2>(
  F: Functor1<F>,
  G: Compactable2<G> & Functor2<G>
): CompactableComposition12<F, G>
export declare function getCompactableComposition<F extends URIS, G extends URIS>(
  F: Functor1<F>,
  G: Compactable1<G> & Functor1<G>
): CompactableComposition11<F, G>
export declare function getCompactableComposition<F, G>(
  F: Functor<F>,
  G: Compactable<G> & Functor<G>
): CompactableComposition<F, G>

Added in v2.0.0 v2.0.0 中添加

Console overview  控制台概述

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


utils   实用程序

error   错误

Signature 签名

export declare const error: <A>(a: A) => IO<void>

Added in v2.0.0 v2.0.0 中添加

info   信息

Signature 签名

export declare const info: <A>(a: A) => IO<void>

Added in v2.0.0 v2.0.0 中添加

log   日志

Signature 签名

export declare const log: <A>(a: A) => IO<void>

Added in v2.0.0 v2.0.0 中添加

warn   警告

Signature 签名

export declare const warn: <A>(a: A) => IO<void>

Added in v2.0.0 v2.0.0 中添加

Const overview  常量概述

The Const type constructor, which wraps its first type argument and ignores its second. That is, Const<E, A> is isomorphic to E for any A.
Const 类型构造函数,包装其第一个类型参数并忽略第二个类型参数。也就是说,对于任何 AConst<E, A>E 同构。

Const has some useful instances. For example, the Applicative instance allows us to collect results using a Monoid while ignoring return values.
Const 有一些有用的实例。例如, Applicative 实例允许我们使用 Monoid 收集结果,同时忽略返回值。

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


constructors  构造函数

make   制作

Signature 签名

export declare const make: <E, A = never>(e: E) => Const<E, A>

Added in v2.0.0 v2.0.0 中添加

error handling   错误处理

mapLeft   地图左

Map a function over the first type argument of a bifunctor.
将函数映射到双函子的第一个类型参数上。

Signature 签名

export declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: Const<E, A>) => Const<G, A>

Added in v2.6.2 v2.6.2 中添加

instances   实例

Bifunctor   双函子

Signature 签名

export declare const Bifunctor: Bifunctor2<'Const'>

Added in v2.7.0 v2.7.0 中添加

Contravariant  逆变

Signature 签名

export declare const Contravariant: Contravariant2<'Const'>

Added in v2.7.0 v2.7.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor2<'Const'>

Added in v2.7.0 v2.7.0 中添加

getApplicative  获取应用程序

Signature 签名

export declare function getApplicative<E>(M: Monoid<E>): Applicative2C<URI, E>

Added in v2.0.0 v2.0.0 中添加

getApply   获取申请

Signature 签名

export declare function getApply<E>(S: Semigroup<E>): Apply2C<URI, E>

Added in v2.0.0 v2.0.0 中添加

getBooleanAlgebra   获取布尔代数

Signature 签名

export declare const getBooleanAlgebra: <E, A>(H: BooleanAlgebra<E>) => BooleanAlgebra<Const<E, A>>

Added in v2.6.0 v2.6.0 中添加

getBounded   获取边界

Signature 签名

export declare const getBounded: <E, A>(B: Bounded<E>) => Bounded<Const<E, A>>

Added in v2.6.0 v2.6.0 中添加

getEq   得到方程

Signature 签名

export declare const getEq: <E, A>(E: Eq<E>) => Eq<Const<E, A>>

Added in v2.0.0 v2.0.0 中添加

getHeytingAlgebra   获取海廷代数

Signature 签名

export declare const getHeytingAlgebra: <E, A>(H: HeytingAlgebra<E>) => HeytingAlgebra<Const<E, A>>

Added in v2.6.0 v2.6.0 中添加

getMonoid   获取Monoid

Signature 签名

export declare const getMonoid: <E, A>(M: Monoid<E>) => Monoid<Const<E, A>>

Added in v2.6.0 v2.6.0 中添加

getOrd   获取订单

Signature 签名

export declare const getOrd: <E, A>(O: Ord<E>) => Ord<Const<E, A>>

Added in v2.6.0 v2.6.0 中添加

getRing   获取铃声

Signature 签名

export declare const getRing: <E, A>(S: Ring<E>) => Ring<Const<E, A>>

Added in v2.6.0 v2.6.0 中添加

getSemigroup   获取半群

Signature 签名

export declare const getSemigroup: <E, A>(S: Semigroup<E>) => Semigroup<Const<E, A>>

Added in v2.6.0 v2.6.0 中添加

getSemiring   获取Semiring

Signature 签名

export declare const getSemiring: <E, A>(S: Semiring<E>) => Semiring<Const<E, A>>

Added in v2.6.0 v2.6.0 中添加

getShow   获取显示

Signature 签名

export declare function getShow<E, A>(S: Show<E>): Show<Const<E, A>>

Added in v2.0.0 v2.0.0 中添加

mapping   映射

bimap   双图

Map a pair of functions over the two type arguments of the bifunctor.
将一对函数映射到双函子的两个类型参数上。

Signature 签名

export declare const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: Const<E, A>) => Const<G, B>

Added in v2.6.2 v2.6.2 中添加

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <E, B>(fab: Const<E, (a: A) => B>) => Const<E, B>

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => <E>(fa: Const<E, A>) => Const<E, B>

Added in v2.0.0 v2.0.0 中添加

model   模型

Const (type alias)
Const(类型别名)

Signature 签名

export type Const<E, A> = E & { readonly _A: A }

Added in v2.0.0 v2.0.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'Const'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

contramap   对比图

Signature 签名

export declare const contramap: <A, B>(f: (b: B) => A) => <E>(fa: Const<E, A>) => Const<E, B>

Added in v2.0.0 v2.0.0 中添加

zone of death
死亡地带

const_ 常量_

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass C.Functor instead of C.const_ (where C is from import C from 'fp-ts/Const')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 C.Functor 而不是 C.const_ (其中 C 来自 import C from 'fp-ts/Const'

Signature 签名

export declare const const_: Functor2<'Const'> & Contravariant2<'Const'> & Bifunctor2<'Const'>

Added in v2.0.0 v2.0.0 中添加

Contravariant overview  逆变概述

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Contravariant (interface)
逆变(接口)

Signature 签名

export interface Contravariant<F> {
  readonly URI: F
  readonly contramap: <A, B>(fa: HKT<F, A>, f: (b: B) => A) => HKT<F, B>
}

Added in v2.0.0 v2.0.0 中添加

Contravariant1 (interface)
逆变1(接口)

Signature 签名

export interface Contravariant1<F extends URIS> {
  readonly URI: F
  readonly contramap: <A, B>(fa: Kind<F, A>, f: (b: B) => A) => Kind<F, B>
}

Added in v2.0.0 v2.0.0 中添加

Contravariant2 (interface)
逆变2(接口)

Signature 签名

export interface Contravariant2<F extends URIS2> {
  readonly URI: F
  readonly contramap: <E, A, B>(fa: Kind2<F, E, A>, f: (b: B) => A) => Kind2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

Contravariant2C (interface)
逆变2C(接口)

Signature 签名

export interface Contravariant2C<F extends URIS2, E> {
  readonly URI: F
  readonly _E: E
  readonly contramap: <A, B>(fa: Kind2<F, E, A>, f: (b: B) => A) => Kind2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

Contravariant3 (interface)
逆变3(接口)

Signature 签名

export interface Contravariant3<F extends URIS3> {
  readonly URI: F
  readonly contramap: <R, E, A, B>(fa: Kind3<F, R, E, A>, f: (b: B) => A) => Kind3<F, R, E, B>
}

Added in v2.0.0 v2.0.0 中添加

Contravariant3C (interface)
逆变3C(接口)

Signature 签名

export interface Contravariant3C<F extends URIS3, E> {
  readonly URI: F
  readonly _E: E
  readonly contramap: <R, A, B>(fa: Kind3<F, R, E, A>, f: (b: B) => A) => Kind3<F, R, E, B>
}

Added in v2.2.0 v2.2.0中添加

Contravariant4 (interface)
逆变4(接口)

Signature 签名

export interface Contravariant4<F extends URIS4> {
  readonly URI: F
  readonly contramap: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, f: (b: B) => A) => Kind4<F, S, R, E, B>
}

Added in v2.0.0 v2.0.0 中添加

Date overview  日期概览

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


constructors  构造函数

create   创造

Returns the current Date 返回当前的 Date

Signature 签名

export declare const create: IO<Date>

Added in v2.0.0 v2.0.0 中添加

instances   实例

Eq   方程

Signature 签名

export declare const Eq: E.Eq<Date>

Added in v2.10.0 v2.10.0 中添加

Ord   奥德

Signature 签名

export declare const Ord: O.Ord<Date>

Example 例子

import { Ord } from 'fp-ts/Date'

assert.deepStrictEqual(Ord.compare(new Date(1, 1, 2020), new Date(1, 1, 2021)), -1)

Added in v2.10.0 v2.10.0 中添加

eqDate   等日期

Signature 签名

export declare const eqDate: E.Eq<Date>

Added in v2.6.0 v2.6.0 中添加

eqMonth   等月

Signature 签名

export declare const eqMonth: E.Eq<Date>

Added in v2.6.0 v2.6.0 中添加

eqYear   等值年

Signature 签名

export declare const eqYear: E.Eq<Date>

Added in v2.6.0 v2.6.0 中添加

utils   实用程序

now   现在

Returns the number of milliseconds elapsed since January 1, 1970, 00:00:00 UTC
返回自 1970 年 1 月 1 日 00:00:00 UTC 以来经过的毫秒数

Signature 签名

export declare const now: IO<number>

Added in v2.0.0 v2.0.0 中添加

DistributiveLattice overview
分配格概述

A DistributiveLattice must satisfy the following laws in addition to Lattice laws:
除了 Lattice 法则之外, DistributiveLattice 还必须满足以下法则:

  • Distributivity for meet: a ∨ (b ∧ c) <-> (a ∨ b) ∧ (a ∨ c)
    满足分配率: a ∨ (b ∧ c) <-> (a ∨ b) ∧ (a ∨ c)
  • Distributivity for join: a ∧ (b ∨ c) <-> (a ∧ b) ∨ (a ∧ c)
    连接的分配性: a ∧ (b ∨ c) <-> (a ∧ b) ∨ (a ∧ c)

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


constructors  构造函数

getMinMaxDistributiveLattice
获取最小最大分布格

Signature 签名

export declare function getMinMaxDistributiveLattice<A>(O: Ord<A>): DistributiveLattice<A>

Added in v2.0.0 v2.0.0 中添加

model   模型

DistributiveLattice (interface)
分布格(接口)

Signature 签名

export interface DistributiveLattice<A> extends Lattice<A> {}

Added in v2.0.0 v2.0.0 中添加

Either overview  任一概述

type Either<E, A> = Left<E> | Right<A>

Represents a value of one of two possible types (a disjoint union).
表示两种可能类型之一的值(不相交并集)。

An instance of Either is either an instance of Left or Right.
Either 的实例是 LeftRight 的实例。

A common use of Either is as an alternative to Option for dealing with possible missing values. In this usage, None is replaced with a Left which can contain useful information. Right takes the place of Some. Convention dictates that Left is used for failure and Right is used for success.
Either 的常见用途是作为 Option 的替代方案来处理可能的缺失值。在此用法中, None 替换为可以包含有用信息的 LeftRight 取代 Some 。按照约定, Left 用于表示失败, Right 用于表示成功。

Example 例子

import * as E from 'fp-ts/Either'
import { pipe } from 'fp-ts/function'

const double = (n: number): number => n * 2

export const imperative = (as: ReadonlyArray<number>): string => {
  const head = (as: ReadonlyArray<number>): number => {
    if (as.length === 0) {
      throw new Error('empty array')
    }
    return as[0]
  }
  const inverse = (n: number): number => {
    if (n === 0) {
      throw new Error('cannot divide by zero')
    }
    return 1 / n
  }
  try {
    return `Result is ${inverse(double(head(as)))}`
  } catch (err: any) {
    return `Error is ${err.message}`
  }
}

export const functional = (as: ReadonlyArray<number>): string => {
  const head = <A>(as: ReadonlyArray<A>): E.Either<string, A> =>
    as.length === 0 ? E.left('empty array') : E.right(as[0])
  const inverse = (n: number): E.Either<string, number> => (n === 0 ? E.left('cannot divide by zero') : E.right(1 / n))
  return pipe(
    as,
    head,
    E.map(double),
    E.flatMap(inverse),
    E.match(
      (err) => `Error is ${err}`, // onLeft handler
      (head) => `Result is ${head}` // onRight handler
    )
  )
}

assert.deepStrictEqual(imperative([1, 2, 3]), functional([1, 2, 3]))
assert.deepStrictEqual(imperative([]), functional([]))
assert.deepStrictEqual(imperative([0]), functional([0]))

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


combinators   组合器

tap   轻敲

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tap: {
  <E1, A, E2, _>(self: Either<E1, A>, f: (a: A) => Either<E2, _>): Either<E1 | E2, A>
  <A, E2, _>(f: (a: A) => Either<E2, _>): <E1>(self: Either<E1, A>) => Either<E2 | E1, A>
}

Added in v2.15.0 v2.15.0 中添加

constructors  构造函数

left  左边

Constructs a new Either holding a Left value. This usually represents a failure, due to the right-bias of this structure.
构造一个新的 Either ,保存 Left 值。由于该结构的右偏,这通常代表失败。

Signature 签名

export declare const left: <E = never, A = never>(e: E) => Either<E, A>

Added in v2.0.0 v2.0.0 中添加

of  

Signature 签名

export declare const of: <E = never, A = never>(a: A) => Either<E, A>

Added in v2.7.0 v2.7.0 中添加

Constructs a new Either holding a Right value. This usually represents a successful value due to the right bias of this structure.
构造一个新的 Either ,保存 Right 值。由于该结构的正确偏差,这通常代表成功的值。

Signature 签名

export declare const right: <E = never, A = never>(a: A) => Either<E, A>

Added in v2.0.0 v2.0.0 中添加

conversions   转换

fromNullable   来自可为空的

Takes a default and a nullable value, if the value is not nully, turn it into a Right, if the value is nully use the provided default as a Left.
接受一个默认值和一个可为空的值,如果该值不为空,则将其转换为 Right ,如果该值为空,则使用提供的默认值作为 Left

Signature 签名

export declare const fromNullable: <E>(e: E) => <A>(a: A) => Either<E, NonNullable<A>>

Example 例子

import { fromNullable, left, right } from 'fp-ts/Either'

const parse = fromNullable('nully')

assert.deepStrictEqual(parse(1), right(1))
assert.deepStrictEqual(parse(null), left('nully'))

Added in v2.0.0 v2.0.0 中添加

fromOption   来自选项

Signature 签名

export declare const fromOption: <E>(onNone: LazyArg<E>) => <A>(fa: Option<A>) => Either<E, A>

Example 例子

import * as E from 'fp-ts/Either'
import { pipe } from 'fp-ts/function'
import * as O from 'fp-ts/Option'

assert.deepStrictEqual(
  pipe(
    O.some(1),
    E.fromOption(() => 'error')
  ),
  E.right(1)
)
assert.deepStrictEqual(
  pipe(
    O.none,
    E.fromOption(() => 'error')
  ),
  E.left('error')
)

Added in v2.0.0 v2.0.0 中添加

toUnion   至联盟

Signature 签名

export declare const toUnion: <E, A>(fa: Either<E, A>) => E | A

Added in v2.10.0 v2.10.0 中添加

do notation   做记号

Do  

Signature 签名

export declare const Do: Either<never, {}>

Added in v2.9.0 v2.9.0中添加

apS   apS

Signature 签名

export declare const apS: <N, A, E, B>(
  name: Exclude<N, keyof A>,
  fb: Either<E, B>
) => (fa: Either<E, A>) => Either<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

apSW   apSW

Less strict version of apS.
apS 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const apSW: <A, N extends string, E2, B>(
  name: Exclude<N, keyof A>,
  fb: Either<E2, B>
) => <E1>(fa: Either<E1, A>) => Either<E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bind   绑定

Signature 签名

export declare const bind: <N, A, E, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => Either<E, B>
) => (ma: Either<E, A>) => Either<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bindTo   绑定到

Signature 签名

export declare const bindTo: <N>(name: N) => <E, A>(fa: Either<E, A>) => Either<E, { readonly [K in N]: A }>

Added in v2.8.0 v2.8.0 中添加

bindW   绑定W

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const bindW: <N extends string, A, E2, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => Either<E2, B>
) => <E1>(fa: Either<E1, A>) => Either<E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

let  

Signature 签名

export declare const let: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => <E>(fa: Either<E, A>) => Either<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.13.0 v2.13.0 中添加

error handling   错误处理

alt   替代

Identifies an associative operation on a type constructor. It is similar to Semigroup, except that it applies to types of kind * -> *.
标识类型构造函数上的关联操作。它与 Semigroup 类似,但它适用于 * -> * 类型。

In case of Either returns the left-most non-Left value (or the right-most Left value if both values are Left).
如果是 Either ,则返回最左边的非 Left 值(如果两个值都是 Left ,则返回最右边的 Left 值)。

x X y y pipe(x, alt(() => y)
管道(x,alt(()=> y)
left(a) 左(一) left(b) 左(b) left(b) 左(b)
left(a) 左(一) right(2) 右(2) right(2) 右(2)
right(1) 右(1) left(b) 左(b) right(1) 右(1)
right(1) 右(1) right(2) 右(2) right(1) 右(1)

Signature 签名

export declare const alt: <E, A>(that: LazyArg<Either<E, A>>) => (fa: Either<E, A>) => Either<E, A>

Example 例子

import * as E from 'fp-ts/Either'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(
  pipe(
    E.left('a'),
    E.alt(() => E.left('b'))
  ),
  E.left('b')
)
assert.deepStrictEqual(
  pipe(
    E.left('a'),
    E.alt(() => E.right(2))
  ),
  E.right(2)
)
assert.deepStrictEqual(
  pipe(
    E.right(1),
    E.alt(() => E.left('b'))
  ),
  E.right(1)
)
assert.deepStrictEqual(
  pipe(
    E.right(1),
    E.alt(() => E.right(2))
  ),
  E.right(1)
)

Added in v2.0.0 v2.0.0 中添加

altW   替代W

Less strict version of alt.
alt 的不太严格版本。

The W suffix (short for Widening) means that the error and the return types will be merged.
W 后缀(Widening 的缩写)意味着错误和返回类型将被合并。

Signature 签名

export declare const altW: <E2, B>(that: LazyArg<Either<E2, B>>) => <E1, A>(fa: Either<E1, A>) => Either<E2, B | A>

Added in v2.9.0 v2.9.0中添加

getAltValidation   获取Alt验证

The default Alt instance returns the last error, if you want to get all errors you need to provide a way to concatenate them via a Semigroup.
默认的 Alt 实例返回最后一个错误,如果你想获取所有错误,你需要提供一种通过 Semigroup 连接它们的方法。

Signature 签名

export declare const getAltValidation: <E>(SE: Semigroup<E>) => Alt2C<'Either', E>

Example 例子

import * as E from 'fp-ts/Either'
import { pipe } from 'fp-ts/function'
import * as S from 'fp-ts/Semigroup'
import * as string from 'fp-ts/string'

const parseString = (u: unknown): E.Either<string, string> =>
  typeof u === 'string' ? E.right(u) : E.left('not a string')

const parseNumber = (u: unknown): E.Either<string, number> =>
  typeof u === 'number' ? E.right(u) : E.left('not a number')

const parse = (u: unknown): E.Either<string, string | number> =>
  pipe(
    parseString(u),
    E.alt<string, string | number>(() => parseNumber(u))
  )

assert.deepStrictEqual(parse(true), E.left('not a number')) // <= last error

const Alt = E.getAltValidation(pipe(string.Semigroup, S.intercalate(', ')))

const parseAll = (u: unknown): E.Either<string, string | number> =>
  Alt.alt<string | number>(parseString(u), () => parseNumber(u))

assert.deepStrictEqual(parseAll(true), E.left('not a string, not a number')) // <= all errors

Added in v2.7.0 v2.7.0 中添加

getApplicativeValidation
获取应用验证

The default Applicative instance returns the first error, if you want to get all errors you need to provide a way to concatenate them via a Semigroup.
默认的 Applicative 实例返回第一个错误,如果您想获取所有错误,您需要提供一种通过 Semigroup 连接它们的方法。

Signature 签名

export declare const getApplicativeValidation: <E>(SE: Semigroup<E>) => Applicative2C<'Either', E>

Example 例子

import * as A from 'fp-ts/Apply'
import * as E from 'fp-ts/Either'
import { pipe } from 'fp-ts/function'
import * as S from 'fp-ts/Semigroup'
import * as string from 'fp-ts/string'

const parseString = (u: unknown): E.Either<string, string> =>
  typeof u === 'string' ? E.right(u) : E.left('not a string')

const parseNumber = (u: unknown): E.Either<string, number> =>
  typeof u === 'number' ? E.right(u) : E.left('not a number')

interface Person {
  readonly name: string
  readonly age: number
}

const parsePerson = (input: Record<string, unknown>): E.Either<string, Person> =>
  pipe(E.Do, E.apS('name', parseString(input.name)), E.apS('age', parseNumber(input.age)))

assert.deepStrictEqual(parsePerson({}), E.left('not a string')) // <= first error

const Applicative = E.getApplicativeValidation(pipe(string.Semigroup, S.intercalate(', ')))

const apS = A.apS(Applicative)

const parsePersonAll = (input: Record<string, unknown>): E.Either<string, Person> =>
  pipe(E.Do, apS('name', parseString(input.name)), apS('age', parseNumber(input.age)))

assert.deepStrictEqual(parsePersonAll({}), E.left('not a string, not a number')) // <= all errors

Added in v2.7.0 v2.7.0 中添加

getOrElse  获取或否则

Returns the wrapped value if it’s a Right or a default value if is a Left.
如果是 Right ,则返回包装值;如果是 Left ,则返回默认值。

Signature 签名

export declare const getOrElse: <E, A>(onLeft: (e: E) => A) => (ma: Either<E, A>) => A

Example 例子

import { getOrElse, left, right } from 'fp-ts/Either'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(
  pipe(
    right(1),
    getOrElse(() => 0)
  ),
  1
)
assert.deepStrictEqual(
  pipe(
    left('error'),
    getOrElse(() => 0)
  ),
  0
)

Added in v2.0.0 v2.0.0 中添加

getOrElseW   获取或否则W

Less strict version of getOrElse.
getOrElse 的不太严格版本。

The W suffix (short for Widening) means that the handler return type will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const getOrElseW: <E, B>(onLeft: (e: E) => B) => <A>(ma: Either<E, A>) => B | A

Added in v2.6.0 v2.6.0 中添加

mapLeft   地图左

Map a function over the first type argument of a bifunctor.
将函数映射到双函子的第一个类型参数上。

Signature 签名

export declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: Either<E, A>) => Either<G, A>

Added in v2.0.0 v2.0.0 中添加

orElse   要不然

Useful for recovering from errors.
对于从错误中恢复很有用。

Signature 签名

export declare const orElse: <E1, A, E2>(onLeft: (e: E1) => Either<E2, A>) => (ma: Either<E1, A>) => Either<E2, A>

Added in v2.0.0 v2.0.0 中添加

orElseW   否则W

Less strict version of orElse.
orElse 的不太严格版本。

The W suffix (short for Widening) means that the return types will be merged.
W 后缀(Widening 的缩写)意味着返回类型将被合并。

Signature 签名

export declare const orElseW: <E1, E2, B>(
  onLeft: (e: E1) => Either<E2, B>
) => <A>(ma: Either<E1, A>) => Either<E2, B | A>

Added in v2.10.0 v2.10.0 中添加

filtering   过滤

filterOrElse  过滤器或者其他

Signature 签名

export declare const filterOrElse: {
  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (self: Either<E, A>) => Either<E, B>
  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(self: Either<E, B>) => Either<E, B>
  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (self: Either<E, A>) => Either<E, A>
}

Example 例子

import * as E from 'fp-ts/Either'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(
  pipe(
    E.right(1),
    E.filterOrElse(
      (n) => n > 0,
      () => 'error'
    )
  ),
  E.right(1)
)
assert.deepStrictEqual(
  pipe(
    E.right(-1),
    E.filterOrElse(
      (n) => n > 0,
      () => 'error'
    )
  ),
  E.left('error')
)
assert.deepStrictEqual(
  pipe(
    E.left('a'),
    E.filterOrElse(
      (n) => n > 0,
      () => 'error'
    )
  ),
  E.left('a')
)

Added in v2.0.0 v2.0.0 中添加

filterOrElseW   过滤器否则W

Less strict version of filterOrElse.
filterOrElse 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const filterOrElseW: {
  <A, B extends A, E2>(refinement: Refinement<A, B>, onFalse: (a: A) => E2): <E1>(
    ma: Either<E1, A>
  ) => Either<E2 | E1, B>
  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <E1, B extends A>(mb: Either<E1, B>) => Either<E2 | E1, B>
  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <E1>(ma: Either<E1, A>) => Either<E2 | E1, A>
}

Added in v2.9.0 v2.9.0中添加

getCompactable   获取可压缩的

Builds a Compactable instance for Either given Monoid for the left side.
为左侧指定 MonoidEither 构建一个 Compactable 实例。

Signature 签名

export declare const getCompactable: <E>(M: Monoid<E>) => Compactable2C<'Either', E>

Added in v2.10.0 v2.10.0 中添加

getFilterable   获取可过滤的

Builds a Filterable instance for Either given Monoid for the left side
为左侧指定 MonoidEither 构建一个 Filterable 实例

Signature 签名

export declare const getFilterable: <E>(M: Monoid<E>) => Filterable2C<'Either', E>

Added in v2.10.0 v2.10.0 中添加

getWitherable   变得枯萎

Builds Witherable instance for Either given Monoid for the left side
Either 构建 Witherable 实例,给定左侧 Monoid

Signature 签名

export declare const getWitherable: <E>(M: Monoid<E>) => Witherable2C<'Either', E>

Added in v2.0.0 v2.0.0 中添加

folding   折叠式的

foldMap   折叠图

Map each element of the structure to a monoid, and combine the results.
将结构的每个元素映射到幺半群,然后组合结果。

Signature 签名

export declare const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <E>(fa: Either<E, A>) => M

Example 例子

import { pipe } from 'fp-ts/function'
import * as E from 'fp-ts/Either'
import * as S from 'fp-ts/string'

const yell = (a: string) => `${a}!`

assert.deepStrictEqual(pipe(E.right('a'), E.foldMap(S.Monoid)(yell)), 'a!')

assert.deepStrictEqual(pipe(E.left('e'), E.foldMap(S.Monoid)(yell)), S.Monoid.empty)

Added in v2.0.0 v2.0.0 中添加

reduce   减少

Left-associative fold of a structure.
结构的左关联折叠。

Signature 签名

export declare const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <E>(fa: Either<E, A>) => B

Example 例子

import { pipe } from 'fp-ts/function'
import * as E from 'fp-ts/Either'

const startWith = 'prefix'
const concat = (a: string, b: string) => `${a}:${b}`

assert.deepStrictEqual(pipe(E.right('a'), E.reduce(startWith, concat)), 'prefix:a')

assert.deepStrictEqual(pipe(E.left('e'), E.reduce(startWith, concat)), 'prefix')

Added in v2.0.0 v2.0.0 中添加

reduceRight   减少右

Right-associative fold of a structure.
结构的右关联折叠。

Signature 签名

export declare const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <E>(fa: Either<E, A>) => B

Example 例子

import { pipe } from 'fp-ts/function'
import * as E from 'fp-ts/Either'

const startWith = 'postfix'
const concat = (a: string, b: string) => `${a}:${b}`

assert.deepStrictEqual(pipe(E.right('a'), E.reduceRight(startWith, concat)), 'a:postfix')

assert.deepStrictEqual(pipe(E.left('e'), E.reduceRight(startWith, concat)), 'postfix')

Added in v2.0.0 v2.0.0 中添加

instances   实例

Alt   替代

Signature 签名

export declare const Alt: Alt2<'Either'>

Added in v2.7.0 v2.7.0 中添加

Applicative   适用性

Signature 签名

export declare const Applicative: Applicative2<'Either'>

Added in v2.7.0 v2.7.0 中添加

Apply   申请

Signature 签名

export declare const Apply: Apply2<'Either'>

Added in v2.10.0 v2.10.0 中添加

Bifunctor   双函子

Signature 签名

export declare const Bifunctor: Bifunctor2<'Either'>

Added in v2.7.0 v2.7.0 中添加

Chain  

Signature 签名

export declare const Chain: chainable.Chain2<'Either'>

Added in v2.10.0 v2.10.0 中添加

ChainRec   链录

Signature 签名

export declare const ChainRec: ChainRec2<'Either'>

Added in v2.7.0 v2.7.0 中添加

Extend   延长

Signature 签名

export declare const Extend: Extend2<'Either'>

Added in v2.7.0 v2.7.0 中添加

Foldable   折叠式

Signature 签名

export declare const Foldable: Foldable2<'Either'>

Added in v2.7.0 v2.7.0 中添加

FromEither   来自任一

Signature 签名

export declare const FromEither: FromEither2<'Either'>

Added in v2.10.0 v2.10.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor2<'Either'>

Added in v2.7.0 v2.7.0 中添加

Monad   单子

Signature 签名

export declare const Monad: Monad2<'Either'>

Added in v2.7.0 v2.7.0 中添加

MonadThrow   单子投掷

Signature 签名

export declare const MonadThrow: MonadThrow2<'Either'>

Added in v2.7.0 v2.7.0 中添加

Pointed  

Signature 签名

export declare const Pointed: Pointed2<'Either'>

Added in v2.10.0 v2.10.0 中添加

Traversable   可穿越

Signature 签名

export declare const Traversable: Traversable2<'Either'>

Added in v2.7.0 v2.7.0 中添加

getEq   得到方程

Signature 签名

export declare const getEq: <E, A>(EL: Eq<E>, EA: Eq<A>) => Eq<Either<E, A>>

Added in v2.0.0 v2.0.0 中添加

getSemigroup   获取半群

Semigroup returning the left-most non-Left value. If both operands are Rights then the inner values are concatenated using the provided Semigroup
半群返回最左边的非 Left 值。如果两个操作数都是 Right s,则使用提供的 Semigroup 连接内部值

Signature 签名

export declare const getSemigroup: <E, A>(S: Semigroup<A>) => Semigroup<Either<E, A>>

Example 例子

import { getSemigroup, left, right } from 'fp-ts/Either'
import { SemigroupSum } from 'fp-ts/number'

const S = getSemigroup<string, number>(SemigroupSum)
assert.deepStrictEqual(S.concat(left('a'), left('b')), left('a'))
assert.deepStrictEqual(S.concat(left('a'), right(2)), right(2))
assert.deepStrictEqual(S.concat(right(1), left('b')), right(1))
assert.deepStrictEqual(S.concat(right(1), right(2)), right(3))

Added in v2.0.0 v2.0.0 中添加

getShow   获取显示

Signature 签名

export declare const getShow: <E, A>(SE: Show<E>, SA: Show<A>) => Show<Either<E, A>>

Added in v2.0.0 v2.0.0 中添加

interop   互操作

tryCatch   试着抓

Constructs a new Either from a function that might throw.
从可能抛出异常的函数构造一个新的 Either

See also tryCatchK. 另请参阅 tryCatchK

Signature 签名

export declare const tryCatch: <E, A>(f: LazyArg<A>, onThrow: (e: unknown) => E) => Either<E, A>

Example 例子

import * as E from 'fp-ts/Either'

const unsafeHead = <A>(as: ReadonlyArray<A>): A => {
  if (as.length > 0) {
    return as[0]
  } else {
    throw new Error('empty array')
  }
}

const head = <A>(as: ReadonlyArray<A>): E.Either<Error, A> =>
  E.tryCatch(
    () => unsafeHead(as),
    (e) => (e instanceof Error ? e : new Error('unknown error'))
  )

assert.deepStrictEqual(head([]), E.left(new Error('empty array')))
assert.deepStrictEqual(head([1, 2, 3]), E.right(1))

Added in v2.0.0 v2.0.0 中添加

tryCatchK   尝试捕获K

Converts a function that may throw to one returning a Either.
将可能抛出异常的函数转换为返回 Either 的函数。

Signature 签名

export declare const tryCatchK: <A extends readonly unknown[], B, E>(
  f: (...a: A) => B,
  onThrow: (error: unknown) => E
) => (...a: A) => Either<E, B>

Added in v2.10.0 v2.10.0 中添加

legacy   遗产

chain  

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chain: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: Either<E, A>) => Either<E, B>

Added in v2.0.0 v2.0.0 中添加

chainFirst   链优先

Alias of tap.  tap 的别名。

Signature 签名

export declare const chainFirst: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: Either<E, A>) => Either<E, A>

Added in v2.0.0 v2.0.0 中添加

chainFirstW  链优先W

Alias of tap.  tap 的别名。

Signature 签名

export declare const chainFirstW: <E2, A, B>(
  f: (a: A) => Either<E2, B>
) => <E1>(ma: Either<E1, A>) => Either<E2 | E1, A>

Added in v2.8.0 v2.8.0 中添加

chainNullableK   链可空K

Use flatMapNullable. 使用 flatMapNullable

Signature 签名

export declare const chainNullableK: <E>(
  e: E
) => <A, B>(f: (a: A) => B | null | undefined) => (ma: Either<E, A>) => Either<E, NonNullable<B>>

Added in v2.9.0 v2.9.0中添加

chainOptionK   链选项K

Use flatMapOption. 使用 flatMapOption

Signature 签名

export declare const chainOptionK: <E>(
  onNone: LazyArg<E>
) => <A, B>(f: (a: A) => Option<B>) => (ma: Either<E, A>) => Either<E, B>

Added in v2.11.0 v2.11.0 中添加

chainOptionKW   链条选项KW

Use flatMapOption. 使用 flatMapOption

Signature 签名

export declare const chainOptionKW: <E2>(
  onNone: LazyArg<E2>
) => <A, B>(f: (a: A) => Option<B>) => <E1>(ma: Either<E1, A>) => Either<E2 | E1, B>

Added in v2.13.2 v2.13.2 中添加

chainW   链W

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chainW: <E2, A, B>(f: (a: A) => Either<E2, B>) => <E1>(ma: Either<E1, A>) => Either<E2 | E1, B>

Added in v2.6.0 v2.6.0 中添加

fromNullableK  来自可空K

Use liftNullable. 使用 liftNullable

Signature 签名

export declare const fromNullableK: <E>(
  e: E
) => <A extends readonly unknown[], B>(f: (...a: A) => B | null | undefined) => (...a: A) => Either<E, NonNullable<B>>

Added in v2.9.0 v2.9.0中添加

fromOptionK   来自选项K

Use liftOption. 使用 liftOption

Signature 签名

export declare const fromOptionK: <E>(
  onNone: LazyArg<E>
) => <A extends readonly unknown[], B>(f: (...a: A) => Option<B>) => (...a: A) => Either<E, B>

Added in v2.10.0 v2.10.0 中添加

lifting   起重

fromPredicate   来自谓词

Signature 签名

export declare const fromPredicate: {
  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => Either<E, B>
  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => Either<E, B>
  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => Either<E, A>
}

Example 例子

import { fromPredicate, left, right } from 'fp-ts/Either'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(
  pipe(
    1,
    fromPredicate(
      (n) => n > 0,
      () => 'error'
    )
  ),
  right(1)
)
assert.deepStrictEqual(
  pipe(
    -1,
    fromPredicate(
      (n) => n > 0,
      () => 'error'
    )
  ),
  left('error')
)

Added in v2.0.0 v2.0.0 中添加

liftNullable   提升可为空

Signature 签名

export declare const liftNullable: <A extends readonly unknown[], B, E>(
  f: (...a: A) => B | null | undefined,
  onNullable: (...a: A) => E
) => (...a: A) => Either<E, NonNullable<B>>

Added in v2.15.0 v2.15.0 中添加

liftOption   电梯选项

Signature 签名

export declare const liftOption: <A extends readonly unknown[], B, E>(
  f: (...a: A) => Option<B>,
  onNone: (...a: A) => E
) => (...a: A) => Either<E, B>

Added in v2.15.0 v2.15.0 中添加

mapping   映射

as   作为

Maps the Right value of this Either to the specified constant value.
将此 EitherRight 值映射到指定的常量值。

Signature 签名

export declare const as: {
  <A>(a: A): <E, _>(self: Either<E, _>) => Either<E, A>
  <E, _, A>(self: Either<E, _>, a: A): Either<E, A>
}

Added in v2.16.0 v2.16.0 中添加

asUnit   作为单位

Maps the Right value of this Either to the void constant value.
将此 EitherRight 值映射到void 常量值。

Signature 签名

export declare const asUnit: <E, _>(self: Either<E, _>) => Either<E, void>

Added in v2.16.0 v2.16.0 中添加

bimap   双图

Map a pair of functions over the two type arguments of the bifunctor.
将一对函数映射到双函子的两个类型参数上。

Signature 签名

export declare const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: Either<E, A>) => Either<G, B>

Added in v2.0.0 v2.0.0 中添加

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <E, B>(fab: Either<E, (a: A) => B>) => Either<E, B>

Added in v2.10.0 v2.10.0 中添加

map   地图

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => <E>(fa: Either<E, A>) => Either<E, B>

Added in v2.0.0 v2.0.0 中添加

model   模型

Either (type alias)
要么(类型别名)

Signature 签名

export type Either<E, A> = Left<E> | Right<A>

Added in v2.0.0 v2.0.0 中添加

Left (interface)   左(接口)

Signature 签名

export interface Left<E> {
  readonly _tag: 'Left'
  readonly left: E
}

Added in v2.0.0 v2.0.0 中添加

Right (interface)   右(接口)

Signature 签名

export interface Right<A> {
  readonly _tag: 'Right'
  readonly right: A
}

Added in v2.0.0 v2.0.0 中添加

pattern matching   模式匹配

fold   折叠

Alias of match.  match 的别名。

Signature 签名

export declare const fold: <E, A, B>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: Either<E, A>) => B

Added in v2.0.0 v2.0.0 中添加

foldW   折叠W

Alias of matchW.  matchW 的别名。

Signature 签名

export declare const foldW: <E, B, A, C>(onLeft: (e: E) => B, onRight: (a: A) => C) => (ma: Either<E, A>) => B | C

Added in v2.10.0 v2.10.0 中添加

match   匹配

Takes two functions and an Either value, if the value is a Left the inner value is applied to the first function, if the value is a Right the inner value is applied to the second function.
接受两个函数和一个 Either 值,如果该值为 Left ,则内部值应用于第一个函数,如果该值为 Right ,则内部值应用于第二个函数。

Signature 签名

export declare const match: <E, A, B>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: Either<E, A>) => B

Example 例子

import { match, left, right } from 'fp-ts/Either'
import { pipe } from 'fp-ts/function'

function onLeft(errors: Array<string>): string {
  return `Errors: ${errors.join(', ')}`
}

function onRight(value: number): string {
  return `Ok: ${value}`
}

assert.strictEqual(pipe(right(1), match(onLeft, onRight)), 'Ok: 1')
assert.strictEqual(pipe(left(['error 1', 'error 2']), match(onLeft, onRight)), 'Errors: error 1, error 2')

Added in v2.10.0 v2.10.0 中添加

matchW   匹配W

Less strict version of match.
match 的不太严格版本。

The W suffix (short for Widening) means that the handler return types will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const matchW: <E, B, A, C>(onLeft: (e: E) => B, onRight: (a: A) => C) => (ma: Either<E, A>) => B | C

Added in v2.10.0 v2.10.0 中添加

refinements   改进

isLeft   离开了

Returns true if the either is an instance of Left, false otherwise.
如果其中之一是 Left 的实例,则返回 true ,否则返回 false

Signature 签名

export declare const isLeft: <E>(ma: Either<E, unknown>) => ma is Left<E>

Added in v2.0.0 v2.0.0 中添加

isRight   是对的

Returns true if the either is an instance of Right, false otherwise.
如果其中之一是 Right 的实例,则返回 true ,否则返回 false

Signature 签名

export declare const isRight: <A>(ma: Either<unknown, A>) => ma is Right<A>

Added in v2.0.0 v2.0.0 中添加

sequencing   测序

flatMap   平面地图

Signature 签名

export declare const flatMap: {
  <A, E2, B>(f: (a: A) => Either<E2, B>): <E1>(ma: Either<E1, A>) => Either<E2 | E1, B>
  <E1, A, E2, B>(ma: Either<E1, A>, f: (a: A) => Either<E2, B>): Either<E1 | E2, B>
}

Added in v2.14.0 v2.14.0 中添加

flatMapNullable   平面地图可空

Signature 签名

export declare const flatMapNullable: {
  <A, B, E2>(f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): <E1>(
    self: Either<E1, A>
  ) => Either<E2 | E1, NonNullable<B>>
  <E1, A, B, E2>(self: Either<E1, A>, f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): Either<
    E1 | E2,
    NonNullable<B>
  >
}

Added in v2.15.0 v2.15.0 中添加

flatMapOption   平面地图选项

Signature 签名

export declare const flatMapOption: {
  <A, B, E2>(f: (a: A) => Option<B>, onNone: (a: A) => E2): <E1>(self: Either<E1, A>) => Either<E2 | E1, B>
  <E1, A, B, E2>(self: Either<E1, A>, f: (a: A) => Option<B>, onNone: (a: A) => E2): Either<E1 | E2, B>
}

Added in v2.15.0 v2.15.0 中添加

flatten   压扁

The flatten function is the conventional monad join operator. It is used to remove one level of monadic structure, projecting its bound argument into the outer level.
flatten 函数是传统的 monad 连接运算符。它用于删除一层单子结构,将其绑定参数投射到外层。

Signature 签名

export declare const flatten: <E, A>(mma: Either<E, Either<E, A>>) => Either<E, A>

Example 例子

import * as E from 'fp-ts/Either'

assert.deepStrictEqual(E.flatten(E.right(E.right('a'))), E.right('a'))
assert.deepStrictEqual(E.flatten(E.right(E.left('e'))), E.left('e'))
assert.deepStrictEqual(E.flatten(E.left('e')), E.left('e'))

Added in v2.0.0 v2.0.0 中添加

flattenW   展平W

Less strict version of flatten.
flatten 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const flattenW: <E1, E2, A>(mma: Either<E1, Either<E2, A>>) => Either<E1 | E2, A>

Added in v2.11.0 v2.11.0 中添加

traversing   穿越

sequence   顺序

Evaluate each monadic action in the structure from left to right, and collect the results.
从左到右评估结构中的每个单子动作,并收集结果。

Signature 签名

export declare const sequence: Sequence2<'Either'>

Example 例子

import { pipe } from 'fp-ts/function'
import * as E from 'fp-ts/Either'
import * as O from 'fp-ts/Option'

assert.deepStrictEqual(pipe(E.right(O.some('a')), E.sequence(O.Applicative)), O.some(E.right('a')))

assert.deepStrictEqual(pipe(E.right(O.none), E.sequence(O.Applicative)), O.none)

Added in v2.6.3 v2.6.3 中添加

sequenceArray   序列数组

Equivalent to ReadonlyArray#sequence(Applicative). 相当于 ReadonlyArray#sequence(Applicative)

Signature 签名

export declare const sequenceArray: <E, A>(as: readonly Either<E, A>[]) => Either<E, readonly A[]>

Added in v2.9.0 v2.9.0中添加

traverse   遍历

Map each element of a structure to an action, evaluate these actions from left to right, and collect the results.
将结构的每个元素映射到一个操作,从左到右评估这些操作,并收集结果。

Signature 签名

export declare const traverse: PipeableTraverse2<'Either'>

Example 例子

import { pipe } from 'fp-ts/function'
import * as RA from 'fp-ts/ReadonlyArray'
import * as E from 'fp-ts/Either'
import * as O from 'fp-ts/Option'

assert.deepStrictEqual(pipe(E.right(['a']), E.traverse(O.Applicative)(RA.head)), O.some(E.right('a')))

assert.deepStrictEqual(pipe(E.right([]), E.traverse(O.Applicative)(RA.head)), O.none)

Added in v2.6.3 v2.6.3 中添加

traverseArray   遍历数组

Equivalent to ReadonlyArray#traverse(Applicative). 相当于 ReadonlyArray#traverse(Applicative)

Signature 签名

export declare const traverseArray: <E, A, B>(
  f: (a: A) => Either<E, B>
) => (as: readonly A[]) => Either<E, readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseArrayWithIndex   带索引遍历数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseArrayWithIndex: <E, A, B>(
  f: (index: number, a: A) => Either<E, B>
) => (as: readonly A[]) => Either<E, readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseReadonlyArrayWithIndex
遍历带索引的只读数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseReadonlyArrayWithIndex: <A, E, B>(
  f: (index: number, a: A) => Either<E, B>
) => (as: readonly A[]) => Either<E, readonly B[]>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyNonEmptyArrayWithIndex
遍历ReadonlyNonEmptyArrayWithIndex

Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(Applicative). 相当于 ReadonlyNonEmptyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseReadonlyNonEmptyArrayWithIndex: <A, E, B>(
  f: (index: number, a: A) => Either<E, B>
) => (as: ReadonlyNonEmptyArray<A>) => Either<E, ReadonlyNonEmptyArray<B>>

Added in v2.11.0 v2.11.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'Either'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

ApT   易于

Signature 签名

export declare const ApT: Either<never, readonly []>

Added in v2.11.0 v2.11.0 中添加

ap   美联社

Signature 签名

export declare const ap: <E, A>(fa: Either<E, A>) => <B>(fab: Either<E, (a: A) => B>) => Either<E, B>

Added in v2.0.0 v2.0.0 中添加

apFirst   应用程序第一

Combine two effectful actions, keeping only the result of the first.
结合两个有效的操作,仅保留第一个操作的结果。

Signature 签名

export declare const apFirst: <E, B>(second: Either<E, B>) => <A>(first: Either<E, A>) => Either<E, A>

Added in v2.0.0 v2.0.0 中添加

apFirstW   apFirstW

Less strict version of apFirst
apFirst 的不太严格版本

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const apFirstW: <E2, B>(second: Either<E2, B>) => <E1, A>(first: Either<E1, A>) => Either<E2 | E1, A>

Added in v2.12.0 v2.12.0 中添加

apSecond   ap秒

Combine two effectful actions, keeping only the result of the second.
结合两个有效的操作,只保留第二个的结果。

Signature 签名

export declare const apSecond: <E, B>(second: Either<E, B>) => <A>(first: Either<E, A>) => Either<E, B>

Added in v2.0.0 v2.0.0 中添加

apSecondW   apSecondW

Less strict version of apSecond
apSecond 的不太严格版本

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const apSecondW: <E2, B>(second: Either<E2, B>) => <E1, A>(first: Either<E1, A>) => Either<E2 | E1, B>

Added in v2.12.0 v2.12.0 中添加

apW   平均功率

Less strict version of ap.
ap 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const apW: <E2, A>(fa: Either<E2, A>) => <E1, B>(fab: Either<E1, (a: A) => B>) => Either<E2 | E1, B>

Added in v2.8.0 v2.8.0 中添加

duplicate   复制

Signature 签名

export declare const duplicate: <E, A>(ma: Either<E, A>) => Either<E, Either<E, A>>

Added in v2.0.0 v2.0.0 中添加

elem   埃莱姆

Signature 签名

export declare function elem<A>(E: Eq<A>): {
  (a: A): <E>(ma: Either<E, A>) => boolean
  <E>(a: A, ma: Either<E, A>): boolean
}

Added in v2.0.0 v2.0.0 中添加

exists   存在

Returns false if Left or returns the result of the application of the given predicate to the Right value.
如果 Left 则返回 false ,或者返回给定谓词应用到 Right 值的结果。

Signature 签名

export declare const exists: <A>(predicate: Predicate<A>) => (ma: Either<unknown, A>) => boolean

Example 例子

import { exists, left, right } from 'fp-ts/Either'

const gt2 = exists((n: number) => n > 2)

assert.strictEqual(gt2(left('a')), false)
assert.strictEqual(gt2(right(1)), false)
assert.strictEqual(gt2(right(3)), true)

Added in v2.0.0 v2.0.0 中添加

extend   延长

Signature 签名

export declare const extend: <E, A, B>(f: (wa: Either<E, A>) => B) => (wa: Either<E, A>) => Either<E, B>

Added in v2.0.0 v2.0.0 中添加

swap   交换

Returns a Right if is a Left (and vice versa).
如果是 Left 则返回 Right (反之亦然)。

Signature 签名

export declare const swap: <E, A>(ma: Either<E, A>) => Either<A, E>

Added in v2.0.0 v2.0.0 中添加

throwError   抛出错误

Signature 签名

export declare const throwError: <E, A>(e: E) => Either<E, A>

Added in v2.6.3 v2.6.3 中添加

toError   错误

Default value for the onError argument of tryCatch
tryCatchonError 参数的默认值

Signature 签名

export declare function toError(e: unknown): Error

Added in v2.0.0 v2.0.0 中添加

zone of death
死亡地带

JsonArray Json数组 (interface)   (界面)

Use Json module instead. 请改用 Json 模块。

Signature 签名

export interface JsonArray extends ReadonlyArray<Json> {}

Added in v2.6.7 v2.6.7 中添加

JsonRecord Json记录 (interface)   (界面)

Use Json module instead. 请改用 Json 模块。

Signature 签名

export interface JsonRecord {
  readonly [key: string]: Json
}

Added in v2.6.7 v2.6.7 中添加

Json 杰森 (type alias)   (类型别名)

Use Json module instead. 请改用 Json 模块。

Signature 签名

export type Json = boolean | number | string | null | JsonArray | JsonRecord

Added in v2.6.7 v2.6.7 中添加

either 任何一个

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass E.Functor instead of E.either (where E is from import E from 'fp-ts/Either')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 E.Functor 而不是 E.either (其中 E 来自 import E from 'fp-ts/Either'

Signature 签名

export declare const either: Monad2<'Either'> &
  Foldable2<'Either'> &
  Traversable2<'Either'> &
  Bifunctor2<'Either'> &
  Alt2<'Either'> &
  Extend2<'Either'> &
  ChainRec2<'Either'> &
  MonadThrow2<'Either'>

Added in v2.0.0 v2.0.0 中添加

getApplyMonoid 获取应用Monoid

Use getApplicativeMonoid instead. 请改用 getApplicativeMonoid

Signature 签名

export declare const getApplyMonoid: <E, A>(M: Monoid<A>) => Monoid<Either<E, A>>

Added in v2.0.0 v2.0.0 中添加

getApplySemigroup 获取ApplySemigroup

Use getApplySemigroup instead. 请改用 getApplySemigroup

Semigroup returning the left-most Left value. If both operands are Rights then the inner values are concatenated using the provided Semigroup
半群返回最左边的 Left 值。如果两个操作数都是 Right s,则使用提供的 Semigroup 连接内部值

Signature 签名

export declare const getApplySemigroup: <E, A>(S: Semigroup<A>) => Semigroup<Either<E, A>>

Added in v2.0.0 v2.0.0 中添加

getValidationMonoid 获取验证Monoid

Use getApplicativeMonoid instead. 请改用 getApplicativeMonoid

Signature 签名

export declare const getValidationMonoid: <E, A>(SE: Semigroup<E>, MA: Monoid<A>) => Monoid<Either<E, A>>

Added in v2.0.0 v2.0.0 中添加

getValidationSemigroup 获取验证半群

Use getApplySemigroup instead. 请改用 getApplySemigroup

Signature 签名

export declare const getValidationSemigroup: <E, A>(SE: Semigroup<E>, SA: Semigroup<A>) => Semigroup<Either<E, A>>

Added in v2.0.0 v2.0.0 中添加

getValidation 获取验证

Use getApplicativeValidation and getAltValidation instead.
请改用 getApplicativeValidationgetAltValidation

Signature 签名

export declare function getValidation<E>(
  SE: Semigroup<E>
): Monad2C<URI, E> &
  Foldable2<URI> &
  Traversable2<URI> &
  Bifunctor2<URI> &
  Alt2C<URI, E> &
  Extend2<URI> &
  ChainRec2C<URI, E> &
  MonadThrow2C<URI, E>

Added in v2.0.0 v2.0.0 中添加

parseJSON 解析JSON

Use parse instead. 请改用 parse

Signature 签名

export declare function parseJSON<E>(s: string, onError: (reason: unknown) => E): Either<E, Json>

Added in v2.0.0 v2.0.0 中添加

stringifyJSON 字符串化JSON

Use stringify instead. 请改用 stringify

Signature 签名

export declare const stringifyJSON: <E>(u: unknown, onError: (reason: unknown) => E) => Either<E, string>

Added in v2.0.0 v2.0.0 中添加

EitherT overview  要么T概述

The error monad transformer. It can be used to add error handling to other monads.
错误单子转换器。它可用于向其他 monad 添加错误处理。

The of function yields a successful computation, while chain sequences two subcomputations, failing on the first error.
of 函数产生成功的计算,而 chain 对两个子计算进行排序,因第一个错误而失败。

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


error handling   错误处理

altValidation   alt验证

Signature 签名

export declare function altValidation<M extends URIS3, E>(
  M: Monad3<M>,
  S: Semigroup<E>
): <R, ME, A>(
  second: LazyArg<Kind3<M, R, ME, Either<E, A>>>
) => (first: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, Either<E, A>>
export declare function altValidation<M extends URIS3, ME, E>(
  M: Monad3C<M, ME>,
  S: Semigroup<E>
): <R, A>(
  second: LazyArg<Kind3<M, R, ME, Either<E, A>>>
) => (first: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, Either<E, A>>
export declare function altValidation<M extends URIS2, E>(
  M: Monad2<M>,
  S: Semigroup<E>
): <ME, A>(
  second: LazyArg<Kind2<M, ME, Either<E, A>>>
) => (first: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, Either<E, A>>
export declare function altValidation<M extends URIS2, ME, E>(
  M: Monad2C<M, ME>,
  S: Semigroup<E>
): <A>(second: LazyArg<Kind2<M, ME, Either<E, A>>>) => (first: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, Either<E, A>>
export declare function altValidation<M extends URIS, E>(
  M: Monad1<M>,
  S: Semigroup<E>
): <A>(second: LazyArg<Kind<M, Either<E, A>>>) => (first: Kind<M, Either<E, A>>) => Kind<M, Either<E, A>>
export declare function altValidation<M, E>(
  M: Monad<M>,
  S: Semigroup<E>
): <A>(second: LazyArg<HKT<M, Either<E, A>>>) => (first: HKT<M, Either<E, A>>) => HKT<M, Either<E, A>>

Added in v2.10.0 v2.10.0 中添加

orElseFirst   或其他优先

Signature 签名

export declare function orElseFirst<M extends URIS3>(
  M: Monad3<M>
): <E, R, ME, B>(
  onLeft: (e: E) => Kind3<M, R, ME, Either<E, B>>
) => <A>(ma: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, Either<E, A>>
export declare function orElseFirst<M extends URIS3, ME>(
  M: Monad3C<M, ME>
): <E, R, B>(
  onLeft: (e: E) => Kind3<M, R, ME, Either<E, B>>
) => <A>(ma: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, Either<E, A>>
export declare function orElseFirst<M extends URIS2>(
  M: Monad2<M>
): <E, ME, B>(
  onLeft: (e: E) => Kind2<M, ME, Either<E, B>>
) => <A>(ma: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, Either<E, A>>
export declare function orElseFirst<M extends URIS2, ME>(
  M: Monad2C<M, ME>
): <E, B>(
  onLeft: (e: E) => Kind2<M, ME, Either<E, B>>
) => <A>(ma: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, Either<E, A>>
export declare function orElseFirst<M extends URIS>(
  M: Monad1<M>
): <E, B>(onLeft: (e: E) => Kind<M, Either<E, B>>) => <A>(ma: Kind<M, Either<E, A>>) => Kind<M, Either<E, A>>
export declare function orElseFirst<M>(
  M: Monad<M>
): <E, B>(onLeft: (e: E) => HKT<M, Either<E, B>>) => <A>(ma: HKT<M, Either<E, A>>) => HKT<M, Either<E, A>>

Added in v2.11.0 v2.11.0 中添加

orLeft   或向左

Signature 签名

export declare function orLeft<M extends URIS3>(
  M: Monad3<M>
): <E1, R, ME, E2>(
  onLeft: (e: E1) => Kind3<M, R, ME, E2>
) => <A>(fa: Kind3<M, R, ME, Either<E1, A>>) => Kind3<M, R, ME, Either<E2, A>>
export declare function orLeft<M extends URIS3, ME>(
  M: Monad3C<M, ME>
): <E1, R, E2>(
  onLeft: (e: E1) => Kind3<M, R, ME, E2>
) => <A>(fa: Kind3<M, R, ME, Either<E1, A>>) => Kind3<M, R, ME, Either<E2, A>>
export declare function orLeft<M extends URIS2>(
  M: Monad2<M>
): <E1, ME, E2>(
  onLeft: (e: E1) => Kind2<M, ME, E2>
) => <A>(fa: Kind2<M, ME, Either<E1, A>>) => Kind2<M, ME, Either<E2, A>>
export declare function orLeft<M extends URIS2, ME>(
  M: Monad2C<M, ME>
): <E1, E2>(onLeft: (e: E1) => Kind2<M, ME, E2>) => <A>(fa: Kind2<M, ME, Either<E1, A>>) => Kind2<M, ME, Either<E2, A>>
export declare function orLeft<M extends URIS>(
  M: Monad1<M>
): <E1, E2>(onLeft: (e: E1) => Kind<M, E2>) => <A>(fa: Kind<M, Either<E1, A>>) => Kind<M, Either<E2, A>>
export declare function orLeft<M>(
  M: Monad<M>
): <E1, E2>(onLeft: (e: E1) => HKT<M, E2>) => <A>(fa: HKT<M, Either<E1, A>>) => HKT<M, Either<E2, A>>

Added in v2.11.0 v2.11.0 中添加

pattern matching   模式匹配

match   匹配

Signature 签名

export declare function match<F extends URIS3>(
  F: Functor3<F>
): <E, B, A>(
  onLeft: (e: E) => B,
  onRight: (a: A) => B
) => <R, ME>(ma: Kind3<F, R, ME, Either<E, A>>) => Kind3<F, R, ME, B>
export declare function match<F extends URIS3, FE>(
  F: Functor3C<F, FE>
): <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => <R>(ma: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, B>
export declare function match<F extends URIS2>(
  F: Functor2<F>
): <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => <FE>(ma: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, B>
export declare function match<F extends URIS2, FE>(
  F: Functor2C<F, FE>
): <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, B>
export declare function match<F extends URIS>(
  F: Functor1<F>
): <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: Kind<F, Either<E, A>>) => Kind<F, B>
export declare function match<F>(
  F: Functor<F>
): <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: HKT<F, Either<E, A>>) => HKT<F, B>

Added in v2.11.0 v2.11.0 中添加

utils   实用程序

alt   替代

Signature 签名

export declare function alt<M extends URIS3>(
  M: Monad3<M>
): <R, ME, E, A>(
  second: LazyArg<Kind3<M, R, ME, Either<E, A>>>
) => (first: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, Either<E, A>>
export declare function alt<M extends URIS3, ME>(
  M: Monad3C<M, ME>
): <R, E, A>(
  second: LazyArg<Kind3<M, R, ME, Either<E, A>>>
) => (first: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, Either<E, A>>
export declare function alt<M extends URIS2>(
  M: Monad2<M>
): <ME, E, A>(
  second: LazyArg<Kind2<M, ME, Either<E, A>>>
) => (first: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, Either<E, A>>
export declare function alt<M extends URIS2, ME>(
  M: Monad2C<M, ME>
): <E, A>(
  second: LazyArg<Kind2<M, ME, Either<E, A>>>
) => (first: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, Either<E, A>>
export declare function alt<M extends URIS>(
  M: Monad1<M>
): <E, A>(second: LazyArg<Kind<M, Either<E, A>>>) => (first: Kind<M, Either<E, A>>) => Kind<M, Either<E, A>>
export declare function alt<M>(
  M: Monad<M>
): <E, A>(second: LazyArg<HKT<M, Either<E, A>>>) => (first: HKT<M, Either<E, A>>) => HKT<M, Either<E, A>>

Added in v2.10.0 v2.10.0 中添加

ap   美联社

Signature 签名

export declare function ap<F extends URIS3>(
  F: Apply3<F>
): <R, FE, E, A>(
  fa: Kind3<F, R, FE, Either<E, A>>
) => <B>(fab: Kind3<F, R, FE, Either<E, (a: A) => B>>) => Kind3<F, R, FE, Either<E, B>>
export declare function ap<F extends URIS3, FE>(
  F: Apply3C<F, FE>
): <R, E, A>(
  fa: Kind3<F, R, FE, Either<E, A>>
) => <B>(fab: Kind3<F, R, FE, Either<E, (a: A) => B>>) => Kind3<F, R, FE, Either<E, B>>
export declare function ap<F extends URIS2>(
  F: Apply2<F>
): <FE, E, A>(
  fa: Kind2<F, FE, Either<E, A>>
) => <B>(fab: Kind2<F, FE, Either<E, (a: A) => B>>) => Kind2<F, FE, Either<E, B>>
export declare function ap<F extends URIS2, FE>(
  F: Apply2C<F, FE>
): <E, A>(
  fa: Kind2<F, FE, Either<E, A>>
) => <B>(fab: Kind2<F, FE, Either<E, (a: A) => B>>) => Kind2<F, FE, Either<E, B>>
export declare function ap<F extends URIS>(
  F: Apply1<F>
): <E, A>(fa: Kind<F, Either<E, A>>) => <B>(fab: Kind<F, Either<E, (a: A) => B>>) => Kind<F, Either<E, B>>
export declare function ap<F>(
  F: Apply<F>
): <E, A>(fa: HKT<F, Either<E, A>>) => <B>(fab: HKT<F, Either<E, (a: A) => B>>) => HKT<F, Either<E, B>>

Added in v2.10.0 v2.10.0 中添加

bimap   双图

Signature 签名

export declare function bimap<F extends URIS3>(
  F: Functor3<F>
): <E, G, A, B>(
  f: (e: E) => G,
  g: (a: A) => B
) => <R, FE>(self: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, Either<G, B>>
export declare function bimap<F extends URIS3, FE>(
  F: Functor3C<F, FE>
): <E, G, A, B>(
  f: (e: E) => G,
  g: (a: A) => B
) => <R>(self: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, Either<G, B>>
export declare function bimap<F extends URIS2>(
  F: Functor2<F>
): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => <FE>(self: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, Either<G, B>>
export declare function bimap<F extends URIS2, FE>(
  F: Functor2C<F, FE>
): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (self: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, Either<G, B>>
export declare function bimap<F extends URIS>(
  F: Functor1<F>
): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (self: Kind<F, Either<E, A>>) => Kind<F, Either<G, B>>
export declare function bimap<F>(
  F: Functor<F>
): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (self: HKT<F, Either<E, A>>) => HKT<F, Either<G, B>>

Added in v2.10.0 v2.10.0 中添加

chain  

Signature 签名

export declare function chain<M extends URIS3>(
  M: Monad3<M>
): <A, R, ME, E, B>(
  f: (a: A) => Kind3<M, R, ME, Either<E, B>>
) => (ma: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, Either<E, B>>
export declare function chain<M extends URIS3, ME>(
  M: Monad3C<M, ME>
): <A, R, E, B>(
  f: (a: A) => Kind3<M, R, ME, Either<E, B>>
) => (ma: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, Either<E, B>>
export declare function chain<M extends URIS2>(
  M: Monad2<M>
): <A, ME, E, B>(
  f: (a: A) => Kind2<M, ME, Either<E, B>>
) => (ma: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, Either<E, B>>
export declare function chain<M extends URIS2, ME>(
  M: Monad2C<M, ME>
): <A, E, B>(f: (a: A) => Kind2<M, ME, Either<E, B>>) => (ma: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, Either<E, B>>
export declare function chain<M extends URIS>(
  M: Monad1<M>
): <A, E, B>(f: (a: A) => Kind<M, Either<E, B>>) => (ma: Kind<M, Either<E, A>>) => Kind<M, Either<E, B>>
export declare function chain<M>(
  M: Monad<M>
): <A, E, B>(f: (a: A) => HKT<M, Either<E, B>>) => (ma: HKT<M, Either<E, A>>) => HKT<M, Either<E, B>>

Added in v2.10.0 v2.10.0 中添加

chainNullableK   链可空K

Signature 签名

export declare function chainNullableK<M extends URIS3>(
  M: Monad3<M>
): <E>(
  e: E
) => <A, B>(
  f: (a: A) => B | null | undefined
) => <S, R>(ma: Kind3<M, S, R, Either<E, A>>) => Kind3<M, S, R, Either<E, NonNullable<B>>>
export declare function chainNullableK<M extends URIS3, R>(
  M: Monad3C<M, R>
): <E>(
  e: E
) => <A, B>(
  f: (a: A) => B | null | undefined
) => <S>(ma: Kind3<M, S, R, Either<E, A>>) => Kind3<M, S, R, Either<E, NonNullable<B>>>
export declare function chainNullableK<M extends URIS2>(
  M: Monad2<M>
): <E>(
  e: E
) => <A, B>(
  f: (a: A) => B | null | undefined
) => <R>(ma: Kind2<M, R, Either<E, A>>) => Kind2<M, R, Either<E, NonNullable<B>>>
export declare function chainNullableK<M extends URIS2, T>(
  M: Monad2C<M, T>
): <E>(
  e: E
) => <A, B>(
  f: (a: A) => B | null | undefined
) => (ma: Kind2<M, T, Either<E, A>>) => Kind2<M, T, Either<E, NonNullable<B>>>
export declare function chainNullableK<M extends URIS>(
  M: Monad1<M>
): <E>(
  e: E
) => <A, B>(f: (a: A) => B | null | undefined) => (ma: Kind<M, Either<E, A>>) => Kind<M, Either<E, NonNullable<B>>>
export declare function chainNullableK<M>(
  M: Monad<M>
): <E>(
  e: E
) => <A, B>(f: (a: A) => B | null | undefined) => (ma: HKT<M, Either<E, A>>) => HKT<M, Either<E, NonNullable<B>>>

Added in v2.12.0 v2.12.0 中添加

fromNullable   来自可为空的

Signature 签名

export declare function fromNullable<F extends URIS3>(
  F: Pointed3<F>
): <E>(e: E) => <A, S, R>(a: A) => Kind3<F, S, R, Either<E, NonNullable<A>>>
export declare function fromNullable<F extends URIS3, R>(
  F: Pointed3C<F, R>
): <E>(e: E) => <A, S>(a: A) => Kind3<F, S, R, Either<E, NonNullable<A>>>
export declare function fromNullable<F extends URIS2>(
  F: Pointed2<F>
): <E>(e: E) => <A, R>(a: A) => Kind2<F, R, Either<E, NonNullable<A>>>
export declare function fromNullable<F extends URIS2, R>(
  F: Pointed2C<F, R>
): <E>(e: E) => <A>(a: A) => Kind2<F, R, Either<E, NonNullable<A>>>
export declare function fromNullable<F extends URIS>(
  F: Pointed1<F>
): <E>(e: E) => <A>(a: A) => Kind<F, Either<E, NonNullable<A>>>
export declare function fromNullable<F>(F: Pointed<F>): <E>(e: E) => <A>(a: A) => HKT<F, Either<E, NonNullable<A>>>

Added in v2.12.0 v2.12.0 中添加

fromNullableK  来自可空K

Signature 签名

export declare function fromNullableK<F extends URIS3>(
  F: Pointed3<F>
): <E>(
  e: E
) => <A extends ReadonlyArray<unknown>, B>(
  f: (...a: A) => B | null | undefined
) => <S, R>(...a: A) => Kind3<F, S, R, Either<E, NonNullable<B>>>
export declare function fromNullableK<F extends URIS3, R>(
  F: Pointed3C<F, R>
): <E>(
  e: E
) => <A extends ReadonlyArray<unknown>, B>(
  f: (...a: A) => B | null | undefined
) => <S>(...a: A) => Kind3<F, S, R, Either<E, NonNullable<B>>>
export declare function fromNullableK<F extends URIS2>(
  F: Pointed2<F>
): <E>(
  e: E
) => <A extends ReadonlyArray<unknown>, B>(
  f: (...a: A) => B | null | undefined
) => <R>(...a: A) => Kind2<F, R, Either<E, NonNullable<B>>>
export declare function fromNullableK<F extends URIS2, R>(
  F: Pointed2C<F, R>
): <E>(
  e: E
) => <A extends ReadonlyArray<unknown>, B>(
  f: (...a: A) => B | null | undefined
) => (...a: A) => Kind2<F, R, Either<E, NonNullable<B>>>
export declare function fromNullableK<F extends URIS>(
  F: Pointed1<F>
): <E>(
  e: E
) => <A extends ReadonlyArray<unknown>, B>(
  f: (...a: A) => B | null | undefined
) => (...a: A) => Kind<F, Either<E, NonNullable<B>>>
export declare function fromNullableK<F>(
  F: Pointed<F>
): <E>(
  e: E
) => <A extends ReadonlyArray<unknown>, B>(
  f: (...a: A) => B | null | undefined
) => (...a: A) => HKT<F, Either<E, NonNullable<B>>>

Added in v2.12.0 v2.12.0 中添加

getOrElse  获取或否则

Signature 签名

export declare function getOrElse<M extends URIS3>(
  M: Monad3<M>
): <E, R, ME, A>(onLeft: (e: E) => Kind3<M, R, ME, A>) => (ma: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, A>
export declare function getOrElse<M extends URIS3, ME>(
  M: Monad3C<M, ME>
): <E, R, A>(onLeft: (e: E) => Kind3<M, R, ME, A>) => (ma: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, A>
export declare function getOrElse<M extends URIS2>(
  M: Monad2<M>
): <E, ME, A>(onLeft: (e: E) => Kind2<M, ME, A>) => (ma: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, A>
export declare function getOrElse<M extends URIS2, ME>(
  M: Monad2C<M, ME>
): <E, A>(onLeft: (e: E) => Kind2<M, ME, A>) => (ma: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, A>
export declare function getOrElse<M extends URIS>(
  M: Monad1<M>
): <E, A>(onLeft: (e: E) => Kind<M, A>) => (ma: Kind<M, Either<E, A>>) => Kind<M, A>
export declare function getOrElse<M>(
  M: Monad<M>
): <E, A>(onLeft: (e: E) => HKT<M, A>) => (ma: HKT<M, Either<E, A>>) => HKT<M, A>

Added in v2.10.0 v2.10.0 中添加

left  左边

Signature 签名

export declare function left<F extends URIS3>(
  F: Pointed3<F>
): <E, R, FE, A = never>(e: E) => Kind3<F, R, FE, Either<E, A>>
export declare function left<F extends URIS3, FE>(
  F: Pointed3C<F, FE>
): <E, R, A = never>(e: E) => Kind3<F, R, FE, Either<E, A>>
export declare function left<F extends URIS2>(F: Pointed2<F>): <E, FE, A = never>(e: E) => Kind2<F, FE, Either<E, A>>
export declare function left<F extends URIS2, FE>(
  F: Pointed2C<F, FE>
): <E, A = never>(e: E) => Kind2<F, FE, Either<E, A>>
export declare function left<F extends URIS>(F: Pointed1<F>): <E, A = never>(e: E) => Kind<F, Either<E, A>>
export declare function left<F>(F: Pointed<F>): <E, A = never>(e: E) => HKT<F, Either<E, A>>

Added in v2.10.0 v2.10.0 中添加

leftF   左F

Signature 签名

export declare function leftF<F extends URIS3>(
  F: Functor3<F>
): <R, FE, E, A = never>(fe: Kind3<F, R, FE, E>) => Kind3<F, R, FE, Either<E, A>>
export declare function leftF<F extends URIS3, FE>(
  F: Functor3C<F, FE>
): <R, E, A = never>(fe: Kind3<F, R, FE, E>) => Kind3<F, R, FE, Either<E, A>>
export declare function leftF<F extends URIS2>(
  F: Functor2<F>
): <FE, E, A = never>(fe: Kind2<F, FE, E>) => Kind2<F, FE, Either<E, A>>
export declare function leftF<F extends URIS2, FE>(
  F: Functor2C<F, FE>
): <E, A = never>(fe: Kind2<F, FE, E>) => Kind2<F, FE, Either<E, A>>
export declare function leftF<F extends URIS>(F: Functor1<F>): <E, A = never>(fe: Kind<F, E>) => Kind<F, Either<E, A>>
export declare function leftF<F>(F: Functor<F>): <E, A = never>(fe: HKT<F, E>) => HKT<F, Either<E, A>>

Added in v2.10.0 v2.10.0 中添加

map   地图

Signature 签名

export declare function map<F extends URIS3>(
  F: Functor3<F>
): <A, B>(f: (a: A) => B) => <R, FE, E>(fa: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, Either<E, B>>
export declare function map<F extends URIS3, FE>(
  F: Functor3C<F, FE>
): <A, B>(f: (a: A) => B) => <R, E>(fa: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, Either<E, B>>
export declare function map<F extends URIS2>(
  F: Functor2<F>
): <A, B>(f: (a: A) => B) => <FE, E>(fa: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, Either<E, B>>
export declare function map<F extends URIS2, FE>(
  F: Functor2C<F, FE>
): <A, B>(f: (a: A) => B) => <E>(fa: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, Either<E, B>>
export declare function map<F extends URIS>(
  F: Functor1<F>
): <A, B>(f: (a: A) => B) => <E>(fa: Kind<F, Either<E, A>>) => Kind<F, Either<E, B>>
export declare function map<F>(
  F: Functor<F>
): <A, B>(f: (a: A) => B) => <E>(fa: HKT<F, Either<E, A>>) => HKT<F, Either<E, B>>

Added in v2.10.0 v2.10.0 中添加

mapLeft   地图左

Signature 签名

export declare function mapLeft<F extends URIS3>(
  F: Functor3<F>
): <E, G>(f: (e: E) => G) => <R, FE, A>(self: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, Either<G, A>>
export declare function mapLeft<F extends URIS3, FE>(
  F: Functor3C<F, FE>
): <E, G>(f: (e: E) => G) => <R, A>(self: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, Either<G, A>>
export declare function mapLeft<F extends URIS2>(
  F: Functor2<F>
): <E, G>(f: (e: E) => G) => <FE, A>(self: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, Either<G, A>>
export declare function mapLeft<F extends URIS2, FE>(
  F: Functor2C<F, FE>
): <E, G>(f: (e: E) => G) => <A>(self: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, Either<G, A>>
export declare function mapLeft<F extends URIS>(
  F: Functor1<F>
): <E, G>(f: (e: E) => G) => <A>(self: Kind<F, Either<E, A>>) => Kind<F, Either<G, A>>
export declare function mapLeft<F>(
  F: Functor<F>
): <E, G>(f: (e: E) => G) => <A>(self: HKT<F, Either<E, A>>) => HKT<F, Either<G, A>>

Added in v2.10.0 v2.10.0 中添加

matchE   匹配E

Signature 签名

export declare function matchE<M extends URIS3>(
  M: Chain3<M>
): <E, R, FE, B, A>(
  onLeft: (e: E) => Kind3<M, R, FE, B>,
  onRight: (a: A) => Kind3<M, R, FE, B>
) => (ma: Kind3<M, R, FE, Either<E, A>>) => Kind3<M, R, FE, B>
export declare function matchE<M extends URIS3, FE>(
  M: Chain3C<M, FE>
): <E, R, B, A>(
  onLeft: (e: E) => Kind3<M, R, FE, B>,
  onRight: (a: A) => Kind3<M, R, FE, B>
) => (ma: Kind3<M, R, FE, Either<E, A>>) => Kind3<M, R, FE, B>
export declare function matchE<M extends URIS2>(
  M: Chain2<M>
): <E, FE, B, A>(
  onLeft: (e: E) => Kind2<M, FE, B>,
  onRight: (a: A) => Kind2<M, FE, B>
) => (ma: Kind2<M, FE, Either<E, A>>) => Kind2<M, FE, B>
export declare function matchE<M extends URIS2, FE>(
  M: Chain2C<M, FE>
): <E, B, A>(
  onLeft: (e: E) => Kind2<M, FE, B>,
  onRight: (a: A) => Kind2<M, FE, B>
) => (ma: Kind2<M, FE, Either<E, A>>) => Kind2<M, FE, B>
export declare function matchE<M extends URIS>(
  M: Chain1<M>
): <E, B, A>(onLeft: (e: E) => Kind<M, B>, onRight: (a: A) => Kind<M, B>) => (ma: Kind<M, Either<E, A>>) => Kind<M, B>
export declare function matchE<M>(
  M: Chain<M>
): <E, B, A>(onLeft: (e: E) => HKT<M, B>, onRight: (a: A) => HKT<M, B>) => (ma: HKT<M, Either<E, A>>) => HKT<M, B>

Added in v2.10.0 v2.10.0 中添加

orElse   要不然

Signature 签名

export declare function orElse<M extends URIS3>(
  M: Monad3<M>
): <E1, R, ME, E2, A>(
  onLeft: (e: E1) => Kind3<M, R, ME, Either<E2, A>>
) => (ma: Kind3<M, R, ME, Either<E1, A>>) => Kind3<M, R, ME, Either<E2, A>>
export declare function orElse<M extends URIS3, ME>(
  M: Monad3C<M, ME>
): <E1, R, E2, A>(
  onLeft: (e: E1) => Kind3<M, R, ME, Either<E2, A>>
) => (ma: Kind3<M, R, ME, Either<E1, A>>) => Kind3<M, R, ME, Either<E2, A>>
export declare function orElse<M extends URIS2>(
  M: Monad2<M>
): <E1, ME, E2, A>(
  onLeft: (e: E1) => Kind2<M, ME, Either<E2, A>>
) => (ma: Kind2<M, ME, Either<E1, A>>) => Kind2<M, ME, Either<E2, A>>
export declare function orElse<M extends URIS2, ME>(
  M: Monad2C<M, ME>
): <E1, E2, A>(
  onLeft: (e: E1) => Kind2<M, ME, Either<E2, A>>
) => (ma: Kind2<M, ME, Either<E1, A>>) => Kind2<M, ME, Either<E2, A>>
export declare function orElse<M extends URIS>(
  M: Monad1<M>
): <E1, E2, A>(onLeft: (e: E1) => Kind<M, Either<E2, A>>) => (ma: Kind<M, Either<E1, A>>) => Kind<M, Either<E2, A>>
export declare function orElse<M>(
  M: Monad<M>
): <E1, E2, A>(onLeft: (e: E1) => HKT<M, Either<E2, A>>) => (ma: HKT<M, Either<E1, A>>) => HKT<M, Either<E2, A>>

Added in v2.10.0 v2.10.0 中添加

Signature 签名

export declare function right<F extends URIS3>(
  F: Pointed3<F>
): <A, R, FE, E = never>(a: A) => Kind3<F, R, FE, Either<E, A>>
export declare function right<F extends URIS3, FE>(
  F: Pointed3C<F, FE>
): <A, R, E = never>(a: A) => Kind3<F, R, FE, Either<E, A>>
export declare function right<F extends URIS2>(F: Pointed2<F>): <A, FE, E = never>(a: A) => Kind2<F, FE, Either<E, A>>
export declare function right<F extends URIS2, FE>(
  F: Pointed2C<F, FE>
): <A, E = never>(a: A) => Kind2<F, FE, Either<E, A>>
export declare function right<F extends URIS>(F: Pointed1<F>): <A, E = never>(a: A) => Kind<F, Either<E, A>>
export declare function right<F>(F: Pointed<F>): <A, E = never>(a: A) => HKT<F, Either<E, A>>

Added in v2.10.0 v2.10.0 中添加

rightF   右F

Signature 签名

export declare function rightF<F extends URIS3>(
  F: Functor3<F>
): <R, FE, A, E = never>(fa: Kind3<F, R, FE, A>) => Kind3<F, R, FE, Either<E, A>>
export declare function rightF<F extends URIS3, FE>(
  F: Functor3C<F, FE>
): <R, A, E = never>(fa: Kind3<F, R, FE, A>) => Kind3<F, R, FE, Either<E, A>>
export declare function rightF<F extends URIS2>(
  F: Functor2<F>
): <FE, A, E = never>(fa: Kind2<F, FE, A>) => Kind2<F, FE, Either<E, A>>
export declare function rightF<F extends URIS2, FE>(
  F: Functor2C<F, FE>
): <A, E = never>(fa: Kind2<F, FE, A>) => Kind2<F, FE, Either<E, A>>
export declare function rightF<F extends URIS>(F: Functor1<F>): <A, E = never>(fa: Kind<F, A>) => Kind<F, Either<E, A>>
export declare function rightF<F>(F: Functor<F>): <A, E = never>(fa: HKT<F, A>) => HKT<F, Either<E, A>>

Added in v2.10.0 v2.10.0 中添加

swap   交换

Signature 签名

export declare function swap<F extends URIS3>(
  F: Functor3<F>
): <R, FE, E, A>(ma: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, Either<A, E>>
export declare function swap<F extends URIS3, FE>(
  F: Functor3C<F, FE>
): <R, E, A>(ma: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, Either<A, E>>
export declare function swap<F extends URIS2>(
  F: Functor2<F>
): <FE, E, A>(ma: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, Either<A, E>>
export declare function swap<F extends URIS2, FE>(
  F: Functor2C<F, FE>
): <E, A>(ma: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, Either<A, E>>
export declare function swap<F extends URIS>(F: Functor1<F>): <E, A>(ma: Kind<F, Either<E, A>>) => Kind<F, Either<A, E>>
export declare function swap<F>(F: Functor<F>): <E, A>(ma: HKT<F, Either<E, A>>) => HKT<F, Either<A, E>>

Added in v2.10.0 v2.10.0 中添加

toUnion   至联盟

Signature 签名

export declare function toUnion<F extends URIS3>(
  F: Functor3<F>
): <R, FE, E, A>(fa: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, E | A>
export declare function toUnion<F extends URIS3, FE>(
  F: Functor3C<F, FE>
): <R, E, A>(fa: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, E | A>
export declare function toUnion<F extends URIS2>(
  F: Functor2<F>
): <FE, E, A>(fa: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, E | A>
export declare function toUnion<F extends URIS2, FE>(
  F: Functor2C<F, FE>
): <E, A>(fa: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, E | A>
export declare function toUnion<F extends URIS>(F: Functor1<F>): <E, A>(fa: Kind<F, Either<E, A>>) => Kind<F, E | A>
export declare function toUnion<F>(F: Functor<F>): <E, A>(fa: HKT<F, Either<E, A>>) => HKT<F, E | A>

Added in v2.10.0 v2.10.0 中添加

zone of death
死亡地带

EitherM1 要么M1 (interface)   (界面)

Signature 签名

export interface EitherM1<M extends URIS> extends ApplicativeComposition12<M, URI> {
  readonly chain: <E, A, B>(ma: EitherT1<M, E, A>, f: (a: A) => EitherT1<M, E, B>) => EitherT1<M, E, B>
  readonly alt: <E, A>(fa: EitherT1<M, E, A>, that: LazyArg<EitherT1<M, E, A>>) => EitherT1<M, E, A>
  readonly bimap: <E, A, N, B>(ma: EitherT1<M, E, A>, f: (e: E) => N, g: (a: A) => B) => EitherT1<M, N, B>
  readonly mapLeft: <E, A, N>(ma: EitherT1<M, E, A>, f: (e: E) => N) => EitherT1<M, N, A>
  readonly fold: <E, A, R>(
    ma: EitherT1<M, E, A>,
    onLeft: (e: E) => Kind<M, R>,
    onRight: (a: A) => Kind<M, R>
  ) => Kind<M, R>
  readonly getOrElse: <E, A>(ma: EitherT1<M, E, A>, onLeft: (e: E) => Kind<M, A>) => Kind<M, A>
  readonly orElse: <E, A, N>(ma: EitherT1<M, E, A>, onLeft: (e: E) => EitherT1<M, N, A>) => EitherT1<M, N, A>
  readonly swap: <E, A>(ma: EitherT1<M, E, A>) => EitherT1<M, A, E>
  readonly rightM: <E, A>(ma: Kind<M, A>) => EitherT1<M, E, A>
  readonly leftM: <E, A>(me: Kind<M, E>) => EitherT1<M, E, A>
  readonly left: <E, A>(e: E) => EitherT1<M, E, A>
}

Added in v2.0.0 v2.0.0 中添加

EitherM2 要么M2 (interface)   (界面)

Signature 签名

export interface EitherM2<M extends URIS2> extends ApplicativeComposition22<M, URI> {
  readonly chain: <R, E, A, B>(ma: EitherT2<M, R, E, A>, f: (a: A) => EitherT2<M, R, E, B>) => EitherT2<M, R, E, B>
  readonly alt: <R, E, A>(fa: EitherT2<M, R, E, A>, that: LazyArg<EitherT2<M, R, E, A>>) => EitherT2<M, R, E, A>
  readonly bimap: <R, E, A, N, B>(ma: EitherT2<M, R, E, A>, f: (e: E) => N, g: (a: A) => B) => EitherT2<M, R, N, B>
  readonly mapLeft: <R, E, A, N>(ma: EitherT2<M, R, E, A>, f: (e: E) => N) => EitherT2<M, R, N, A>
  readonly fold: <R, E, A, B>(
    ma: EitherT2<M, R, E, A>,
    onLeft: (e: E) => Kind2<M, R, B>,
    onRight: (a: A) => Kind2<M, R, B>
  ) => Kind2<M, R, B>
  readonly getOrElse: <R, E, A>(ma: EitherT2<M, R, E, A>, onLeft: (e: E) => Kind2<M, R, A>) => Kind2<M, R, A>
  readonly orElse: <R, E, A, F>(
    ma: EitherT2<M, R, E, A>,
    onLeft: (e: E) => EitherT2<M, R, F, A>
  ) => EitherT2<M, R, F, A>
  readonly swap: <R, E, A>(ma: EitherT2<M, R, E, A>) => EitherT2<M, R, A, E>
  readonly rightM: <R, E, A>(ma: Kind2<M, R, A>) => EitherT2<M, R, E, A>
  readonly leftM: <R, E, A>(me: Kind2<M, R, E>) => EitherT2<M, R, E, A>
  readonly left: <R, E, A>(e: E) => EitherT2<M, R, E, A>
}

Added in v2.0.0 v2.0.0 中添加

EitherM 要么M (interface)   (界面)

Signature 签名

export interface EitherM<M> extends ApplicativeCompositionHKT2<M, URI> {
  readonly chain: <E, A, B>(ma: EitherT<M, E, A>, f: (a: A) => EitherT<M, E, B>) => EitherT<M, E, B>
  readonly alt: <E, A>(fa: EitherT<M, E, A>, that: LazyArg<EitherT<M, E, A>>) => EitherT<M, E, A>
  readonly bimap: <E, A, N, B>(ma: EitherT<M, E, A>, f: (e: E) => N, g: (a: A) => B) => EitherT<M, N, B>
  readonly mapLeft: <E, A, N>(ma: EitherT<M, E, A>, f: (e: E) => N) => EitherT<M, N, A>
  readonly fold: <E, A, R>(ma: EitherT<M, E, A>, onLeft: (e: E) => HKT<M, R>, onRight: (a: A) => HKT<M, R>) => HKT<M, R>
  readonly getOrElse: <E, A>(ma: EitherT<M, E, A>, onLeft: (e: E) => HKT<M, A>) => HKT<M, A>
  readonly orElse: <E, A, N>(ma: EitherT<M, E, A>, onLeft: (e: E) => EitherT<M, N, A>) => EitherT<M, N, A>
  readonly swap: <E, A>(ma: EitherT<M, E, A>) => EitherT<M, A, E>
  readonly rightM: <E, A>(ma: HKT<M, A>) => EitherT<M, E, A>
  readonly leftM: <E, A>(me: HKT<M, E>) => EitherT<M, E, A>
  readonly left: <E, A>(e: E) => EitherT<M, E, A>
}

Added in v2.0.0 v2.0.0 中添加

EitherT1 要么T1 (type alias)   (类型别名)

Signature 签名

export type EitherT1<M extends URIS, E, A> = Kind<M, Either<E, A>>

Added in v2.0.0 v2.0.0 中添加

EitherT2 要么T2 (type alias)   (类型别名)

Signature 签名

export type EitherT2<M extends URIS2, R, E, A> = Kind2<M, R, Either<E, A>>

Added in v2.0.0 v2.0.0 中添加

EitherT 要么T (interface)   (界面)

Signature 签名

export interface EitherT<M, E, A> extends HKT<M, Either<E, A>> {}

Added in v2.0.0 v2.0.0 中添加

getEitherM 获取任一M

Signature 签名

export declare function getEitherM<M extends URIS2>(M: Monad2<M>): EitherM2<M>
export declare function getEitherM<M extends URIS>(M: Monad1<M>): EitherM1<M>
export declare function getEitherM<M>(M: Monad<M>): EitherM<M>

Added in v2.0.0 v2.0.0 中添加

Endomorphism overview  自同态概述

Added in v2.11.0 v2.11.0 中添加


Table of contents
目录


instances   实例

getMonoid   获取Monoid

Endomorphism form a Monoid where the empty value is the identity function.
同态形成 Monoid ,其中 empty 值是 identity 函数。

Signature 签名

export declare const getMonoid: <A = never>() => Monoid<Endomorphism<A>>

Added in v2.11.0 v2.11.0 中添加

getSemigroup   获取半群

Endomorphism form a Semigroup where the concat operation is the usual function composition.
同态形成 Semigroup ,其中 concat 操作是通常的函数组合。

Signature 签名

export declare const getSemigroup: <A = never>() => Semigroup<Endomorphism<A>>

Added in v2.11.0 v2.11.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'Endomorphism'

Added in v2.11.0 v2.11.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.11.0 v2.11.0 中添加

utils   实用程序

Endomorphism (interface)
自同态(界面)

Signature 签名

export interface Endomorphism<A> {
  (a: A): A
}

Added in v2.11.0 v2.11.0 中添加

Eq overview  情商概述

The Eq type class represents types which support decidable equality.
Eq 类型类表示支持可判定相等的类型。

Instances must satisfy the following laws:
实例必须满足以下定律:

  1. Reflexivity: E.equals(a, a) === true 自反性: E.equals(a, a) === true
  2. Symmetry: E.equals(a, b) === E.equals(b, a) 对称性: E.equals(a, b) === E.equals(b, a)
  3. Transitivity: if E.equals(a, b) === true and E.equals(b, c) === true, then E.equals(a, c) === true
    传递性:如果 E.equals(a, b) === trueE.equals(b, c) === true ,则 E.equals(a, c) === true

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


constructors  构造函数

fromEquals   来自等于

Signature 签名

export declare const fromEquals: <A>(equals: (x: A, y: A) => boolean) => Eq<A>

Added in v2.0.0 v2.0.0 中添加

instances   实例

Contravariant  逆变

Signature 签名

export declare const Contravariant: Contravariant1<'Eq'>

Added in v2.7.0 v2.7.0 中添加

eqStrict   等严格

Signature 签名

export declare const eqStrict: Eq<unknown>

Added in v2.5.0 v2.5.0中添加

getMonoid   获取Monoid

Signature 签名

export declare const getMonoid: <A>() => Monoid<Eq<A>>

Added in v2.6.0 v2.6.0 中添加

getSemigroup   获取半群

Signature 签名

export declare const getSemigroup: <A>() => Semigroup<Eq<A>>

Added in v2.10.0 v2.10.0 中添加

model   模型

Eq (interface)   等式(接口)

Signature 签名

export interface Eq<A> {
  readonly equals: (x: A, y: A) => boolean
}

Added in v2.0.0 v2.0.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'Eq'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

contramap   对比图

A typical use case for contramap would be like, given some User type, to construct an Eq<User>.
contramap 的典型用例类似于,给定一些 User 类型,构造一个 Eq<User>

We can do so with a function from User -> X where X is some value that we know how to compare for equality (meaning we have an Eq<X>)
我们可以使用 User -> X 中的函数来做到这一点,其中 X 是我们知道如何比较相等性的某个值(意味着我们有一个 Eq<X>

For example, given the following User type, we want to construct an Eq<User> that just looks at the key field for each user (since it’s known to be unique).
例如,给定以下 User 类型,我们想要构造一个 Eq<User> ,它只查看每个用户的 key 字段(因为已知它是唯一的)。

If we have a way of comparing UUIDs for equality (eqUUID: Eq<UUID>) and we know how to go from User -> UUID, using contramap we can do this
如果我们有办法比较 UUID s是否相等( eqUUID: Eq<UUID> )并且我们知道如何从 User -> UUID 开始,使用 contramap 我们可以做到这一点

Signature 签名

export declare const contramap: <A, B>(f: (b: B) => A) => (fa: Eq<A>) => Eq<B>

Example 例子

import { contramap, Eq } from 'fp-ts/Eq'
import { pipe } from 'fp-ts/function'
import * as S from 'fp-ts/string'

type UUID = string

interface User {
  readonly key: UUID
  readonly firstName: string
  readonly lastName: string
}

const eqUUID: Eq<UUID> = S.Eq

const eqUserByKey: Eq<User> = pipe(
  eqUUID,
  contramap((user) => user.key)
)

assert.deepStrictEqual(
  eqUserByKey.equals({ key: 'k1', firstName: 'a1', lastName: 'b1' }, { key: 'k2', firstName: 'a1', lastName: 'b1' }),
  false
)
assert.deepStrictEqual(
  eqUserByKey.equals({ key: 'k1', firstName: 'a1', lastName: 'b1' }, { key: 'k1', firstName: 'a2', lastName: 'b1' }),
  true
)

Added in v2.0.0 v2.0.0 中添加

struct   结构体

Signature 签名

export declare const struct: <A>(eqs: { [K in keyof A]: Eq<A[K]> }) => Eq<{ readonly [K in keyof A]: A[K] }>

Added in v2.10.0 v2.10.0 中添加

tuple   元组

Given a tuple of Eqs returns a Eq for the tuple
给定一个 Eq s 的元组,返回该元组的 Eq

Signature 签名

export declare const tuple: <A extends readonly unknown[]>(...eqs: { [K in keyof A]: Eq<A[K]> }) => Eq<Readonly<A>>

Example 例子

import { tuple } from 'fp-ts/Eq'
import * as S from 'fp-ts/string'
import * as N from 'fp-ts/number'
import * as B from 'fp-ts/boolean'

const E = tuple(S.Eq, N.Eq, B.Eq)
assert.strictEqual(E.equals(['a', 1, true], ['a', 1, true]), true)
assert.strictEqual(E.equals(['a', 1, true], ['b', 1, true]), false)
assert.strictEqual(E.equals(['a', 1, true], ['a', 2, true]), false)
assert.strictEqual(E.equals(['a', 1, true], ['a', 1, false]), false)

Added in v2.10.0 v2.10.0 中添加

zone of death
死亡地带

eqBoolean eq布尔值

Use Eq instead. 请改用 Eq

Signature 签名

export declare const eqBoolean: Eq<boolean>

Added in v2.0.0 v2.0.0 中添加

eqDate 等日期

Use Eq instead. 请改用 Eq

Signature 签名

export declare const eqDate: Eq<Date>

Added in v2.0.0 v2.0.0 中添加

eqNumber EQ编号

Use Eq instead. 请改用 Eq

Signature 签名

export declare const eqNumber: Eq<number>

Added in v2.0.0 v2.0.0 中添加

eqString 等式字符串

Use Eq instead. 请改用 Eq

Signature 签名

export declare const eqString: Eq<string>

Added in v2.0.0 v2.0.0 中添加

eq 情商

This instance is deprecated, use small, specific instances instead. For example if a function needs a Contravariant instance, pass E.Contravariant instead of E.eq (where E is from import E from 'fp-ts/Eq')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Contravariant 实例,请传递 E.Contravariant 而不是 E.eq (其中 E 来自 import E from 'fp-ts/Eq'

Signature 签名

export declare const eq: Contravariant1<'Eq'>

Added in v2.0.0 v2.0.0 中添加

getStructEq 获取结构方程

Use struct instead. 请改用 struct

Signature 签名

export declare const getStructEq: <O extends Readonly<Record<string, any>>>(eqs: { [K in keyof O]: Eq<O[K]> }) => Eq<O>

Added in v2.0.0 v2.0.0 中添加

getTupleEq 获取元组方程

Use tuple instead. 请改用 tuple

Signature 签名

export declare const getTupleEq: <T extends readonly Eq<any>[]>(
  ...eqs: T
) => Eq<{ [K in keyof T]: T[K] extends Eq<infer A> ? A : never }>

Added in v2.0.0 v2.0.0 中添加

strictEqual 严格等于

Use eqStrict instead 使用 eqStrict 代替

Signature 签名

export declare const strictEqual: <A>(a: A, b: A) => boolean

Added in v2.0.0 v2.0.0 中添加

Extend overview  扩展概述

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Extend (interface)   扩展(接口)

Signature 签名

export interface Extend<W> extends Functor<W> {
  readonly extend: <A, B>(wa: HKT<W, A>, f: (wa: HKT<W, A>) => B) => HKT<W, B>
}

Added in v2.0.0 v2.0.0 中添加

Extend1 (interface)   扩展1(接口)

Signature 签名

export interface Extend1<W extends URIS> extends Functor1<W> {
  readonly extend: <A, B>(wa: Kind<W, A>, f: (wa: Kind<W, A>) => B) => Kind<W, B>
}

Added in v2.0.0 v2.0.0 中添加

Extend2 (interface)   扩展2(接口)

Signature 签名

export interface Extend2<W extends URIS2> extends Functor2<W> {
  readonly extend: <E, A, B>(wa: Kind2<W, E, A>, f: (wa: Kind2<W, E, A>) => B) => Kind2<W, E, B>
}

Added in v2.0.0 v2.0.0 中添加

Extend2C (interface)   扩展2C(接口)

Signature 签名

export interface Extend2C<W extends URIS2, E> extends Functor2C<W, E> {
  readonly extend: <A, B>(wa: Kind2<W, E, A>, f: (wa: Kind2<W, E, A>) => B) => Kind2<W, E, B>
}

Added in v2.0.0 v2.0.0 中添加

Extend3 (interface)   扩展3(接口)

Signature 签名

export interface Extend3<W extends URIS3> extends Functor3<W> {
  readonly extend: <R, E, A, B>(wa: Kind3<W, R, E, A>, f: (wa: Kind3<W, R, E, A>) => B) => Kind3<W, R, E, B>
}

Added in v2.0.0 v2.0.0 中添加

Extend3C (interface)   扩展3C(接口)

Signature 签名

export interface Extend3C<W extends URIS3, E> extends Functor3C<W, E> {
  readonly extend: <R, A, B>(wa: Kind3<W, R, E, A>, f: (wa: Kind3<W, R, E, A>) => B) => Kind3<W, R, E, B>
}

Added in v2.2.0 v2.2.0中添加

Extend4 (interface)   扩展4(接口)

Signature 签名

export interface Extend4<W extends URIS4> extends Functor4<W> {
  readonly extend: <S, R, E, A, B>(wa: Kind4<W, S, R, E, A>, f: (wa: Kind4<W, S, R, E, A>) => B) => Kind4<W, S, R, E, B>
}

Added in v2.0.0 v2.0.0 中添加

Field overview  领域概览

Adapted from https://github.com/purescript/purescript-prelude/blob/master/src/Data/Field.purs
改编自https://github.com/purescript/purescript-prelude/blob/master/src/Data/Field.purs

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Field (interface)   字段(接口)

Signature 签名

export interface Field<A> extends Ring<A> {
  readonly degree: (a: A) => number
  readonly div: (x: A, y: A) => A
  readonly mod: (x: A, y: A) => A
}

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

gcd   最大CD

The greatest common divisor of two values
两个值的最大公约数

Signature 签名

export declare function gcd<A>(E: Eq<A>, field: Field<A>): (x: A, y: A) => A

Added in v2.0.0 v2.0.0 中添加

lcm   LCM

The least common multiple of two values
两个值的最小公倍数

Signature 签名

export declare function lcm<A>(E: Eq<A>, F: Field<A>): (x: A, y: A) => A

Added in v2.0.0 v2.0.0 中添加

zone of death
死亡地带

fieldNumber 字段编号

Use Field instead. 请改用 Field

Signature 签名

export declare const fieldNumber: Field<number>

Added in v2.0.0 v2.0.0 中添加

Filterable overview  可过滤概述

Filterable represents data structures which can be partitioned/filtered.
Filterable 表示可以分区/过滤的数据结构。

Adapted from https://github.com/LiamGoodacre/purescript-filterable/blob/master/src/Data/Filterable.purs
改编自https://github.com/LiamGoodacre/purescript-filterable/blob/master/src/Data/Filterable.purs

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Filterable (interface)   可过滤(界面)

Signature 签名

export interface Filterable<F> extends Functor<F>, Compactable<F> {
  /**
   * Partition a data structure based on an either predicate.
   */
  readonly partitionMap: <A, B, C>(fa: HKT<F, A>, f: (a: A) => Either<B, C>) => Separated<HKT<F, B>, HKT<F, C>>
  /**
   * Partition a data structure based on a boolean predicate.
   */
  readonly partition: Partition<F>
  /**
   * Map over a data structure and filter based on an option predicate.
   */
  readonly filterMap: <A, B>(fa: HKT<F, A>, f: (a: A) => Option<B>) => HKT<F, B>
  /**
   * Filter a data structure based on a boolean predicate.
   */
  readonly filter: Filter<F>
}

Added in v2.0.0 v2.0.0 中添加

Filterable1 (interface)
可过滤1(接口)

Signature 签名

export interface Filterable1<F extends URIS> extends Functor1<F>, Compactable1<F> {
  readonly partitionMap: <A, B, C>(fa: Kind<F, A>, f: (a: A) => Either<B, C>) => Separated<Kind<F, B>, Kind<F, C>>
  readonly partition: Partition1<F>
  readonly filterMap: <A, B>(fa: Kind<F, A>, f: (a: A) => Option<B>) => Kind<F, B>
  readonly filter: Filter1<F>
}

Added in v2.0.0 v2.0.0 中添加

Filterable2 (interface)
可过滤2(接口)

Signature 签名

export interface Filterable2<F extends URIS2> extends Functor2<F>, Compactable2<F> {
  readonly partitionMap: <E, A, B, C>(
    fa: Kind2<F, E, A>,
    f: (a: A) => Either<B, C>
  ) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>
  readonly partition: Partition2<F>
  readonly filterMap: <E, A, B>(fa: Kind2<F, E, A>, f: (a: A) => Option<B>) => Kind2<F, E, B>
  readonly filter: Filter2<F>
}

Added in v2.0.0 v2.0.0 中添加

Filterable2C (interface)
Filterable2C(接口)

Signature 签名

export interface Filterable2C<F extends URIS2, E> extends Functor2C<F, E>, Compactable2C<F, E> {
  readonly partitionMap: <A, B, C>(
    fa: Kind2<F, E, A>,
    f: (a: A) => Either<B, C>
  ) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>
  readonly partition: Partition2C<F, E>
  readonly filterMap: <A, B>(fa: Kind2<F, E, A>, f: (a: A) => Option<B>) => Kind2<F, E, B>
  readonly filter: Filter2C<F, E>
}

Added in v2.0.0 v2.0.0 中添加

Filterable3 (interface)
可过滤3(界面)

Signature 签名

export interface Filterable3<F extends URIS3> extends Functor3<F>, Compactable3<F> {
  readonly partitionMap: <R, E, A, B, C>(
    fa: Kind3<F, R, E, A>,
    f: (a: A) => Either<B, C>
  ) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>
  readonly partition: Partition3<F>
  readonly filterMap: <R, E, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => Option<B>) => Kind3<F, R, E, B>
  readonly filter: Filter3<F>
}

Added in v2.0.0 v2.0.0 中添加

Filterable3C (interface)
Filterable3C(接口)

Signature 签名

export interface Filterable3C<F extends URIS3, E> extends Functor3C<F, E>, Compactable3C<F, E> {
  readonly partitionMap: <R, A, B, C>(
    fa: Kind3<F, R, E, A>,
    f: (a: A) => Either<B, C>
  ) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>
  readonly partition: Partition3C<F, E>
  readonly filterMap: <R, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => Option<B>) => Kind3<F, R, E, B>
  readonly filter: Filter3C<F, E>
}

Added in v2.2.0 v2.2.0中添加

Filterable4 (interface)
可过滤4(接口)

Signature 签名

export interface Filterable4<F extends URIS4> extends Functor4<F>, Compactable4<F> {
  readonly partitionMap: <S, R, E, A, B, C>(
    fa: Kind4<F, S, R, E, A>,
    f: (a: A) => Either<B, C>
  ) => Separated<Kind4<F, S, R, E, B>, Kind4<F, S, R, E, C>>
  readonly partition: Partition4<F>
  readonly filterMap: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, f: (a: A) => Option<B>) => Kind4<F, S, R, E, B>
  readonly filter: Filter4<F>
}

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

Filter (interface)   过滤器(接口)

Signature 签名

export interface Filter<F> {
  <A, B extends A>(fa: HKT<F, A>, refinement: Refinement<A, B>): HKT<F, B>
  <A>(fa: HKT<F, A>, predicate: Predicate<A>): HKT<F, A>
}

Added in v2.0.0 v2.0.0 中添加

Filter1 (interface)   过滤器1(接口)

Signature 签名

export interface Filter1<F extends URIS> {
  <A, B extends A>(fa: Kind<F, A>, refinement: Refinement<A, B>): Kind<F, B>
  <A>(fa: Kind<F, A>, predicate: Predicate<A>): Kind<F, A>
}

Added in v2.0.0 v2.0.0 中添加

Filter2 (interface)   过滤器2(接口)

Signature 签名

export interface Filter2<F extends URIS2> {
  <E, A, B extends A>(fa: Kind2<F, E, A>, refinement: Refinement<A, B>): Kind2<F, E, B>
  <E, A>(fa: Kind2<F, E, A>, predicate: Predicate<A>): Kind2<F, E, A>
}

Added in v2.0.0 v2.0.0 中添加

Filter2C (interface)   Filter2C(接口)

Signature 签名

export interface Filter2C<F extends URIS2, E> {
  <A, B extends A>(fa: Kind2<F, E, A>, refinement: Refinement<A, B>): Kind2<F, E, B>
  <A>(fa: Kind2<F, E, A>, predicate: Predicate<A>): Kind2<F, E, A>
}

Added in v2.0.0 v2.0.0 中添加

Filter3 (interface)   过滤器3(接口)

Signature 签名

export interface Filter3<F extends URIS3> {
  <R, E, A, B extends A>(fa: Kind3<F, R, E, A>, refinement: Refinement<A, B>): Kind3<F, R, E, B>
  <R, E, A>(fa: Kind3<F, R, E, A>, predicate: Predicate<A>): Kind3<F, R, E, A>
}

Added in v2.0.0 v2.0.0 中添加

Filter3C (interface)   Filter3C(接口)

Signature 签名

export interface Filter3C<F extends URIS3, E> {
  <R, A, B extends A>(fa: Kind3<F, R, E, A>, refinement: Refinement<A, B>): Kind3<F, R, E, B>
  <R, A>(fa: Kind3<F, R, E, A>, predicate: Predicate<A>): Kind3<F, R, E, A>
}

Added in v2.2.0 v2.2.0中添加

Filter4 (interface)   过滤器4(接口)

Signature 签名

export interface Filter4<F extends URIS4> {
  <S, R, E, A, B extends A>(fa: Kind4<F, S, R, E, A>, refinement: Refinement<A, B>): Kind4<F, S, R, E, B>
  <S, R, E, A>(fa: Kind4<F, S, R, E, A>, predicate: Predicate<A>): Kind4<F, S, R, E, A>
}

Added in v2.0.0 v2.0.0 中添加

Partition (interface)   分区(接口)

Signature 签名

export interface Partition<F> {
  <A, B extends A>(fa: HKT<F, A>, refinement: Refinement<A, B>): Separated<HKT<F, A>, HKT<F, B>>
  <A>(fa: HKT<F, A>, predicate: Predicate<A>): Separated<HKT<F, A>, HKT<F, A>>
}

Added in v2.0.0 v2.0.0 中添加

Partition1 (interface)   分区1(接口)

Signature 签名

export interface Partition1<F extends URIS> {
  <A, B extends A>(fa: Kind<F, A>, refinement: Refinement<A, B>): Separated<Kind<F, A>, Kind<F, B>>
  <A>(fa: Kind<F, A>, predicate: Predicate<A>): Separated<Kind<F, A>, Kind<F, A>>
}

Added in v2.0.0 v2.0.0 中添加

Partition2 (interface)   分区2(接口)

Signature 签名

export interface Partition2<F extends URIS2> {
  <E, A, B extends A>(fa: Kind2<F, E, A>, refinement: Refinement<A, B>): Separated<Kind2<F, E, A>, Kind2<F, E, B>>
  <E, A>(fa: Kind2<F, E, A>, predicate: Predicate<A>): Separated<Kind2<F, E, A>, Kind2<F, E, A>>
}

Added in v2.0.0 v2.0.0 中添加

Partition2C (interface)
Partition2C(接口)

Signature 签名

export interface Partition2C<F extends URIS2, E> {
  <A, B extends A>(fa: Kind2<F, E, A>, refinement: Refinement<A, B>): Separated<Kind2<F, E, A>, Kind2<F, E, B>>
  <A>(fa: Kind2<F, E, A>, predicate: Predicate<A>): Separated<Kind2<F, E, A>, Kind2<F, E, A>>
}

Added in v2.0.0 v2.0.0 中添加

Partition3 (interface)   分区3(接口)

Signature 签名

export interface Partition3<F extends URIS3> {
  <R, E, A, B extends A>(fa: Kind3<F, R, E, A>, refinement: Refinement<A, B>): Separated<
    Kind3<F, R, E, A>,
    Kind3<F, R, E, B>
  >
  <R, E, A>(fa: Kind3<F, R, E, A>, predicate: Predicate<A>): Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>
}

Added in v2.0.0 v2.0.0 中添加

Partition3C (interface)
Partition3C(接口)

Signature 签名

export interface Partition3C<F extends URIS3, E> {
  <R, A, B extends A>(fa: Kind3<F, R, E, A>, refinement: Refinement<A, B>): Separated<
    Kind3<F, R, E, A>,
    Kind3<F, R, E, B>
  >
  <R, A>(fa: Kind3<F, R, E, A>, predicate: Predicate<A>): Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>
}

Added in v2.2.0 v2.2.0中添加

Partition4 (interface)   分区4(接口)

Signature 签名

export interface Partition4<F extends URIS4> {
  <S, R, E, A, B extends A>(fa: Kind4<F, S, R, E, A>, refinement: Refinement<A, B>): Separated<
    Kind4<F, S, R, E, A>,
    Kind4<F, S, R, E, B>
  >
  <S, R, E, A>(fa: Kind4<F, S, R, E, A>, predicate: Predicate<A>): Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, A>>
}

Added in v2.0.0 v2.0.0 中添加

filter   筛选

filter composition.

Signature 签名

export declare function filter<F extends URIS2, G extends URIS2, E>(
  F: Functor2<F>,
  G: Filterable2C<G, E>
): {
  <A, B extends A>(refinement: Refinement<A, B>): <R>(fga: Kind2<F, R, Kind2<G, E, A>>) => Kind2<F, R, Kind2<G, E, B>>
  <A>(predicate: Predicate<A>): <R, B extends A>(fgb: Kind2<F, R, Kind2<G, E, B>>) => Kind2<F, R, Kind2<G, E, B>>
  <A>(predicate: Predicate<A>): <R>(fga: Kind2<F, R, Kind2<G, E, A>>) => Kind2<F, R, Kind2<G, E, A>>
}
export declare function filter<F extends URIS, G extends URIS2, E>(
  F: Functor1<F>,
  G: Filterable2C<G, E>
): {
  <A, B extends A>(refinement: Refinement<A, B>): (fga: Kind<F, Kind2<G, E, A>>) => Kind<F, Kind2<G, E, B>>
  <A>(predicate: Predicate<A>): <B extends A>(fgb: Kind<F, Kind2<G, E, B>>) => Kind<F, Kind2<G, E, B>>
  <A>(predicate: Predicate<A>): (fga: Kind<F, Kind2<G, E, A>>) => Kind<F, Kind2<G, E, A>>
}
export declare function filter<F extends URIS, G extends URIS>(
  F: Functor1<F>,
  G: Filterable1<G>
): {
  <A, B extends A>(refinement: Refinement<A, B>): (fga: Kind<F, Kind<G, A>>) => Kind<F, Kind<G, B>>
  <A>(predicate: Predicate<A>): <B extends A>(fgb: Kind<F, Kind<G, B>>) => Kind<F, Kind<G, B>>
  <A>(predicate: Predicate<A>): (fga: Kind<F, Kind<G, A>>) => Kind<F, Kind<G, A>>
}
export declare function filter<F, G>(
  F: Functor<F>,
  G: Filterable<G>
): {
  <A, B extends A>(refinement: Refinement<A, B>): (fga: HKT<F, HKT<G, A>>) => HKT<F, HKT<G, B>>
  <A>(predicate: Predicate<A>): <B extends A>(fgb: HKT<F, HKT<G, B>>) => HKT<F, HKT<G, B>>
  <A>(predicate: Predicate<A>): (fga: HKT<F, HKT<G, A>>) => HKT<F, HKT<G, A>>
}

Added in v2.10.0 v2.10.0 中添加

filterMap   过滤映射

filterMap composition.

Signature 签名

export declare function filterMap<F extends URIS2, G extends URIS2, E>(
  F: Functor2<F>,
  G: Filterable2C<G, E>
): <A, B>(f: (a: A) => Option<B>) => <FE>(fga: Kind2<F, FE, Kind2<G, E, A>>) => Kind2<F, FE, Kind2<G, E, B>>
export declare function filterMap<F extends URIS, G extends URIS2, E>(
  F: Functor1<F>,
  G: Filterable2C<G, E>
): <A, B>(f: (a: A) => Option<B>) => (fga: Kind<F, Kind2<G, E, A>>) => Kind<F, Kind2<G, E, B>>
export declare function filterMap<F extends URIS, G extends URIS>(
  F: Functor1<F>,
  G: Filterable1<G>
): <A, B>(f: (a: A) => Option<B>) => (fga: Kind<F, Kind<G, A>>) => Kind<F, Kind<G, B>>
export declare function filterMap<F, G>(
  F: Functor<F>,
  G: Filterable<G>
): <A, B>(f: (a: A) => Option<B>) => (fga: HKT<F, HKT<G, A>>) => HKT<F, HKT<G, B>>

Added in v2.10.0 v2.10.0 中添加

partition   分割

partition composition.

Signature 签名

export declare function partition<F extends URIS2, G extends URIS2, E>(
  F: Functor2<F>,
  G: Filterable2C<G, E>
): {
  <A, B extends A>(refinement: Refinement<A, B>): <R>(
    fga: Kind2<F, R, Kind2<G, E, A>>
  ) => Separated<Kind2<F, R, Kind2<G, E, A>>, Kind2<F, R, Kind2<G, E, B>>>
  <A>(predicate: Predicate<A>): <R, B extends A>(
    fgb: Kind2<F, R, Kind2<G, E, B>>
  ) => Separated<Kind2<F, R, Kind2<G, E, B>>, Kind2<F, R, Kind2<G, E, B>>>
  <A>(predicate: Predicate<A>): <R>(
    fga: Kind2<F, R, Kind2<G, E, A>>
  ) => Separated<Kind2<F, R, Kind2<G, E, A>>, Kind2<F, R, Kind2<G, E, A>>>
}
export declare function partition<F extends URIS, G extends URIS2, E>(
  F: Functor1<F>,
  G: Filterable2C<G, E>
): {
  <A, B extends A>(refinement: Refinement<A, B>): (
    fga: Kind<F, Kind2<G, E, A>>
  ) => Separated<Kind<F, Kind2<G, E, A>>, Kind<F, Kind2<G, E, B>>>
  <A>(predicate: Predicate<A>): <B extends A>(
    fgb: Kind<F, Kind2<G, E, B>>
  ) => Separated<Kind<F, Kind2<G, E, B>>, Kind<F, Kind2<G, E, B>>>
  <A>(predicate: Predicate<A>): (
    fga: Kind<F, Kind2<G, E, A>>
  ) => Separated<Kind<F, Kind2<G, E, A>>, Kind<F, Kind2<G, E, A>>>
}
export declare function partition<F extends URIS, G extends URIS>(
  F: Functor1<F>,
  G: Filterable1<G>
): {
  <A, B extends A>(refinement: Refinement<A, B>): (
    fga: Kind<F, Kind<G, A>>
  ) => Separated<Kind<F, Kind<G, A>>, Kind<F, Kind<G, B>>>
  <A>(predicate: Predicate<A>): <B extends A>(
    fgb: Kind<F, Kind<G, B>>
  ) => Separated<Kind<F, Kind<G, B>>, Kind<F, Kind<G, B>>>
  <A>(predicate: Predicate<A>): (fga: Kind<F, Kind<G, A>>) => Separated<Kind<F, Kind<G, A>>, Kind<F, Kind<G, A>>>
}
export declare function partition<F, G>(
  F: Functor<F>,
  G: Filterable<G>
): {
  <A, B extends A>(refinement: Refinement<A, B>): (
    fga: HKT<F, HKT<G, A>>
  ) => Separated<HKT<F, HKT<G, A>>, HKT<F, HKT<G, B>>>
  <A>(predicate: Predicate<A>): <B extends A>(fgb: HKT<F, HKT<G, B>>) => Separated<HKT<F, HKT<G, B>>, HKT<F, HKT<G, B>>>
  <A>(predicate: Predicate<A>): (fga: HKT<F, HKT<G, A>>) => Separated<HKT<F, HKT<G, A>>, HKT<F, HKT<G, A>>>
}

Added in v2.10.0 v2.10.0 中添加

partitionMap   分区图

partitionMap composition.

Signature 签名

export declare function partitionMap<F extends URIS2, G extends URIS2, E>(
  F: Functor2<F>,
  G: Filterable2C<G, E>
): <A, B, C>(
  f: (a: A) => Either<B, C>
) => <FE>(fa: Kind2<F, FE, Kind2<G, E, A>>) => Separated<Kind2<F, FE, Kind2<G, E, B>>, Kind2<F, FE, Kind2<G, E, C>>>
export declare function partitionMap<F extends URIS, G extends URIS2, E>(
  F: Functor1<F>,
  G: Filterable2C<G, E>
): <A, B, C>(
  f: (a: A) => Either<B, C>
) => (fa: Kind<F, Kind2<G, E, A>>) => Separated<Kind<F, Kind2<G, E, B>>, Kind<F, Kind2<G, E, C>>>
export declare function partitionMap<F extends URIS, G extends URIS>(
  F: Functor1<F>,
  G: Filterable1<G>
): <A, B, C>(
  f: (a: A) => Either<B, C>
) => (fa: Kind<F, Kind<G, A>>) => Separated<Kind<F, Kind<G, B>>, Kind<F, Kind<G, C>>>
export declare function partitionMap<F, G>(
  F: Functor<F>,
  G: Filterable<G>
): <A, B, C>(f: (a: A) => Either<B, C>) => (fa: HKT<F, HKT<G, A>>) => Separated<HKT<F, HKT<G, B>>, HKT<F, HKT<G, C>>>

Added in v2.10.0 v2.10.0 中添加

zone of death
死亡地带

FilterableComposition11 可过滤成分11 (interface)   (界面)

Signature 签名

export interface FilterableComposition11<F extends URIS, G extends URIS>
  extends FunctorComposition11<F, G>,
    CompactableComposition11<F, G> {
  readonly partitionMap: <A, B, C>(
    fa: Kind<F, Kind<G, A>>,
    f: (a: A) => Either<B, C>
  ) => Separated<Kind<F, Kind<G, B>>, Kind<F, Kind<G, C>>>
  readonly partition: <A>(
    fa: Kind<F, Kind<G, A>>,
    predicate: Predicate<A>
  ) => Separated<Kind<F, Kind<G, A>>, Kind<F, Kind<G, A>>>
  readonly filterMap: <A, B>(fa: Kind<F, Kind<G, A>>, f: (a: A) => Option<B>) => Kind<F, Kind<G, B>>
  readonly filter: <A>(fa: Kind<F, Kind<G, A>>, predicate: Predicate<A>) => Kind<F, Kind<G, A>>
}

Added in v2.0.0 v2.0.0 中添加

FilterableComposition12C
可过滤组合物12C
(interface)   (界面)

Signature 签名

export interface FilterableComposition12C<F extends URIS, G extends URIS2, E>
  extends FunctorComposition12C<F, G, E>,
    CompactableComposition12C<F, G, E> {
  readonly partitionMap: <A, B, C>(
    fa: Kind<F, Kind2<G, E, A>>,
    f: (a: A) => Either<B, C>
  ) => Separated<Kind<F, Kind2<G, E, B>>, Kind<F, Kind2<G, E, C>>>
  readonly partition: <A>(
    fa: Kind<F, Kind2<G, E, A>>,
    predicate: Predicate<A>
  ) => Separated<Kind<F, Kind2<G, E, A>>, Kind<F, Kind2<G, E, A>>>
  readonly filterMap: <A, B>(fa: Kind<F, Kind2<G, E, A>>, f: (a: A) => Option<B>) => Kind<F, Kind2<G, E, B>>
  readonly filter: <A>(fa: Kind<F, Kind2<G, E, A>>, predicate: Predicate<A>) => Kind<F, Kind2<G, E, A>>
}

Added in v2.0.0 v2.0.0 中添加

FilterableComposition12 可过滤成分12 (interface)   (界面)

Signature 签名

export interface FilterableComposition12<F extends URIS, G extends URIS2>
  extends FunctorComposition12<F, G>,
    CompactableComposition12<F, G> {
  readonly partitionMap: <E, A, B, C>(
    fa: Kind<F, Kind2<G, E, A>>,
    f: (a: A) => Either<B, C>
  ) => Separated<Kind<F, Kind2<G, E, B>>, Kind<F, Kind2<G, E, C>>>
  readonly partition: <E, A>(
    fa: Kind<F, Kind2<G, E, A>>,
    predicate: Predicate<A>
  ) => Separated<Kind<F, Kind2<G, E, A>>, Kind<F, Kind2<G, E, A>>>
  readonly filterMap: <E, A, B>(fa: Kind<F, Kind2<G, E, A>>, f: (a: A) => Option<B>) => Kind<F, Kind2<G, E, B>>
  readonly filter: <E, A>(fa: Kind<F, Kind2<G, E, A>>, predicate: Predicate<A>) => Kind<F, Kind2<G, E, A>>
}

Added in v2.0.0 v2.0.0 中添加

FilterableComposition21 可过滤成分21 (interface)   (界面)

Signature 签名

export interface FilterableComposition21<F extends URIS2, G extends URIS>
  extends FunctorComposition21<F, G>,
    CompactableComposition21<F, G> {
  readonly partitionMap: <E, A, B, C>(
    fa: Kind2<F, E, Kind<G, A>>,
    f: (a: A) => Either<B, C>
  ) => Separated<Kind2<F, E, Kind<G, B>>, Kind2<F, E, Kind<G, C>>>
  readonly partition: <E, A>(
    fa: Kind2<F, E, Kind<G, A>>,
    predicate: Predicate<A>
  ) => Separated<Kind2<F, E, Kind<G, A>>, Kind2<F, E, Kind<G, A>>>
  readonly filterMap: <E, A, B>(fa: Kind2<F, E, Kind<G, A>>, f: (a: A) => Option<B>) => Kind2<F, E, Kind<G, B>>
  readonly filter: <E, A>(fa: Kind2<F, E, Kind<G, A>>, predicate: Predicate<A>) => Kind2<F, E, Kind<G, A>>
}

Added in v2.0.0 v2.0.0 中添加

FilterableComposition22C
可过滤组合物22C
(interface)   (界面)

Signature 签名

export interface FilterableComposition22C<F extends URIS2, G extends URIS2, E>
  extends FunctorComposition22<F, G>,
    CompactableComposition22<F, G> {
  readonly partitionMap: <FE, A, B, C>(
    fa: Kind2<F, FE, Kind2<G, E, A>>,
    f: (a: A) => Either<B, C>
  ) => Separated<Kind2<F, FE, Kind2<G, E, B>>, Kind2<F, FE, Kind2<G, E, C>>>
  readonly partition: <FE, A>(
    fa: Kind2<F, FE, Kind2<G, E, A>>,
    predicate: Predicate<A>
  ) => Separated<Kind2<F, FE, Kind2<G, E, A>>, Kind2<F, FE, Kind2<G, E, A>>>
  readonly filterMap: <FE, A, B>(
    fa: Kind2<F, FE, Kind2<G, E, A>>,
    f: (a: A) => Option<B>
  ) => Kind2<F, FE, Kind2<G, E, B>>
  readonly filter: <FE, A>(fa: Kind2<F, FE, Kind2<G, E, A>>, predicate: Predicate<A>) => Kind2<F, FE, Kind2<G, E, A>>
}

Added in v2.0.0 v2.0.0 中添加

FilterableComposition22 可过滤成分22 (interface)   (界面)

Signature 签名

export interface FilterableComposition22<F extends URIS2, G extends URIS2>
  extends FunctorComposition22<F, G>,
    CompactableComposition22<F, G> {
  readonly partitionMap: <FE, GE, A, B, C>(
    fa: Kind2<F, FE, Kind2<G, GE, A>>,
    f: (a: A) => Either<B, C>
  ) => Separated<Kind2<F, FE, Kind2<G, GE, B>>, Kind2<F, FE, Kind2<G, GE, C>>>
  readonly partition: <FE, GE, A>(
    fa: Kind2<F, FE, Kind2<G, GE, A>>,
    predicate: Predicate<A>
  ) => Separated<Kind2<F, FE, Kind2<G, GE, A>>, Kind2<F, FE, Kind2<G, GE, A>>>
  readonly filterMap: <FE, GE, A, B>(
    fa: Kind2<F, FE, Kind2<G, GE, A>>,
    f: (a: A) => Option<B>
  ) => Kind2<F, FE, Kind2<G, GE, B>>
  readonly filter: <FE, GE, A>(
    fa: Kind2<F, FE, Kind2<G, GE, A>>,
    predicate: Predicate<A>
  ) => Kind2<F, FE, Kind2<G, GE, A>>
}

Added in v2.0.0 v2.0.0 中添加

FilterableComposition23C
可过滤组合物23C
(interface)   (界面)

Signature 签名

export interface FilterableComposition23C<F extends URIS2, G extends URIS3, E>
  extends FunctorComposition23<F, G>,
    CompactableComposition23<F, G> {
  readonly partitionMap: <R, FE, A, B, C>(
    fa: Kind2<F, FE, Kind3<G, R, E, A>>,
    f: (a: A) => Either<B, C>
  ) => Separated<Kind2<F, FE, Kind3<G, R, E, B>>, Kind2<F, FE, Kind3<G, R, E, C>>>
  readonly partition: <R, FE, A>(
    fa: Kind2<F, FE, Kind3<G, R, E, A>>,
    predicate: Predicate<A>
  ) => Separated<Kind2<F, FE, Kind3<G, R, E, A>>, Kind2<F, FE, Kind3<G, R, E, A>>>
  readonly filterMap: <R, FE, A, B>(
    fa: Kind2<F, FE, Kind3<G, R, E, A>>,
    f: (a: A) => Option<B>
  ) => Kind2<F, FE, Kind3<G, R, E, B>>
  readonly filter: <R, FE, A>(
    fa: Kind2<F, FE, Kind3<G, R, E, A>>,
    predicate: Predicate<A>
  ) => Kind2<F, FE, Kind3<G, R, E, A>>
}

Added in v2.2.0 v2.2.0中添加

FilterableComposition2C1
可过滤组合物2C1
(interface)   (界面)

Signature 签名

export interface FilterableComposition2C1<F extends URIS2, G extends URIS, E>
  extends FunctorComposition21<F, G>,
    CompactableComposition21<F, G> {
  readonly partitionMap: <A, B, C>(
    fa: Kind2<F, E, Kind<G, A>>,
    f: (a: A) => Either<B, C>
  ) => Separated<Kind2<F, E, Kind<G, B>>, Kind2<F, E, Kind<G, C>>>
  readonly partition: <A>(
    fa: Kind2<F, E, Kind<G, A>>,
    predicate: Predicate<A>
  ) => Separated<Kind2<F, E, Kind<G, A>>, Kind2<F, E, Kind<G, A>>>
  readonly filterMap: <A, B>(fa: Kind2<F, E, Kind<G, A>>, f: (a: A) => Option<B>) => Kind2<F, E, Kind<G, B>>
  readonly filter: <A>(fa: Kind2<F, E, Kind<G, A>>, predicate: Predicate<A>) => Kind2<F, E, Kind<G, A>>
}

Added in v2.0.0 v2.0.0 中添加

FilterableComposition 可过滤成分 (interface)   (界面)

Signature 签名

export interface FilterableComposition<F, G> extends FunctorComposition<F, G>, CompactableComposition<F, G> {
  readonly partitionMap: <A, B, C>(
    fa: HKT<F, HKT<G, A>>,
    f: (a: A) => Either<B, C>
  ) => Separated<HKT<F, HKT<G, B>>, HKT<F, HKT<G, C>>>
  readonly partition: <A>(
    fa: HKT<F, HKT<G, A>>,
    predicate: Predicate<A>
  ) => Separated<HKT<F, HKT<G, A>>, HKT<F, HKT<G, A>>>
  readonly filterMap: <A, B>(fa: HKT<F, HKT<G, A>>, f: (a: A) => Option<B>) => HKT<F, HKT<G, B>>
  readonly filter: <A>(fa: HKT<F, HKT<G, A>>, predicate: Predicate<A>) => HKT<F, HKT<G, A>>
}

Added in v2.0.0 v2.0.0 中添加

getFilterableComposition
获取可过滤的组合

Use 使用

instead.

Signature 签名

export declare function getFilterableComposition<F extends URIS2, G extends URIS3, E>(
  F: Functor2<F>,
  G: Filterable3C<G, E>
): FilterableComposition23C<F, G, E>
export declare function getFilterableComposition<F extends URIS2, G extends URIS2, E>(
  F: Functor2<F>,
  G: Filterable2C<G, E>
): FilterableComposition22C<F, G, E>
export declare function getFilterableComposition<F extends URIS2, G extends URIS2>(
  F: Functor2<F>,
  G: Filterable2<G>
): FilterableComposition22<F, G>
export declare function getFilterableComposition<F extends URIS2, G extends URIS, E>(
  F: Functor2C<F, E>,
  G: Filterable1<G>
): FilterableComposition2C1<F, G, E>
export declare function getFilterableComposition<F extends URIS2, G extends URIS>(
  F: Functor2<F>,
  G: Filterable1<G>
): FilterableComposition21<F, G>
export declare function getFilterableComposition<F extends URIS, G extends URIS2, E>(
  F: Functor1<F>,
  G: Filterable2C<G, E>
): FilterableComposition12C<F, G, E>
export declare function getFilterableComposition<F extends URIS, G extends URIS2>(
  F: Functor1<F>,
  G: Filterable2<G>
): FilterableComposition12<F, G>
export declare function getFilterableComposition<F extends URIS, G extends URIS>(
  F: Functor1<F>,
  G: Filterable1<G>
): FilterableComposition11<F, G>
export declare function getFilterableComposition<F, G>(F: Functor<F>, G: Filterable<G>): FilterableComposition<F, G>

Added in v2.0.0 v2.0.0 中添加

FilterableWithIndex overview
FilterableWithIndex 概述

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

FilterableWithIndex (interface)
可过滤带索引(接口)

Signature 签名

export interface FilterableWithIndex<F, I> extends FunctorWithIndex<F, I>, Filterable<F> {
  readonly partitionMapWithIndex: <A, B, C>(
    fa: HKT<F, A>,
    f: (i: I, a: A) => Either<B, C>
  ) => Separated<HKT<F, B>, HKT<F, C>>
  readonly partitionWithIndex: PartitionWithIndex<F, I>
  readonly filterMapWithIndex: <A, B>(fa: HKT<F, A>, f: (i: I, a: A) => Option<B>) => HKT<F, B>
  readonly filterWithIndex: FilterWithIndex<F, I>
}

Added in v2.0.0 v2.0.0 中添加

FilterableWithIndex1 (interface)
FilterableWithIndex1(接口)

Signature 签名

export interface FilterableWithIndex1<F extends URIS, I> extends FunctorWithIndex1<F, I>, Filterable1<F> {
  readonly partitionMapWithIndex: <A, B, C>(
    fa: Kind<F, A>,
    f: (i: I, a: A) => Either<B, C>
  ) => Separated<Kind<F, B>, Kind<F, C>>
  readonly partitionWithIndex: PartitionWithIndex1<F, I>
  readonly filterMapWithIndex: <A, B>(fa: Kind<F, A>, f: (i: I, a: A) => Option<B>) => Kind<F, B>
  readonly filterWithIndex: FilterWithIndex1<F, I>
}

Added in v2.0.0 v2.0.0 中添加

FilterableWithIndex2 (interface)
FilterableWithIndex2(接口)

Signature 签名

export interface FilterableWithIndex2<F extends URIS2, I> extends FunctorWithIndex2<F, I>, Filterable2<F> {
  readonly partitionMapWithIndex: <E, A, B, C>(
    fa: Kind2<F, E, A>,
    f: (i: I, a: A) => Either<B, C>
  ) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>
  readonly partitionWithIndex: PartitionWithIndex2<F, I>
  readonly filterMapWithIndex: <E, A, B>(fa: Kind2<F, E, A>, f: (i: I, a: A) => Option<B>) => Kind2<F, E, B>
  readonly filterWithIndex: FilterWithIndex2<F, I>
}

Added in v2.0.0 v2.0.0 中添加

FilterableWithIndex2C (interface)
FilterableWithIndex2C(接口)

Signature 签名

export interface FilterableWithIndex2C<F extends URIS2, I, E> extends FunctorWithIndex2C<F, I, E>, Filterable2C<F, E> {
  readonly partitionMapWithIndex: <A, B, C>(
    fa: Kind2<F, E, A>,
    f: (i: I, a: A) => Either<B, C>
  ) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>
  readonly partitionWithIndex: PartitionWithIndex2C<F, I, E>
  readonly filterMapWithIndex: <A, B>(fa: Kind2<F, E, A>, f: (i: I, a: A) => Option<B>) => Kind2<F, E, B>
  readonly filterWithIndex: FilterWithIndex2C<F, I, E>
}

Added in v2.0.0 v2.0.0 中添加

FilterableWithIndex3 (interface)
FilterableWithIndex3(接口)

Signature 签名

export interface FilterableWithIndex3<F extends URIS3, I> extends FunctorWithIndex3<F, I>, Filterable3<F> {
  readonly partitionMapWithIndex: <R, E, A, B, C>(
    fa: Kind3<F, R, E, A>,
    f: (i: I, a: A) => Either<B, C>
  ) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>
  readonly partitionWithIndex: PartitionWithIndex3<F, I>
  readonly filterMapWithIndex: <R, E, A, B>(fa: Kind3<F, R, E, A>, f: (i: I, a: A) => Option<B>) => Kind3<F, R, E, B>
  readonly filterWithIndex: FilterWithIndex3<F, I>
}

Added in v2.0.0 v2.0.0 中添加

FilterableWithIndex3C (interface)
FilterableWithIndex3C(接口)

Signature 签名

export interface FilterableWithIndex3C<F extends URIS3, I, E> extends FunctorWithIndex3C<F, I, E>, Filterable3C<F, E> {
  readonly partitionMapWithIndex: <R, A, B, C>(
    fa: Kind3<F, R, E, A>,
    f: (i: I, a: A) => Either<B, C>
  ) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>
  readonly partitionWithIndex: PartitionWithIndex3C<F, I, E>
  readonly filterMapWithIndex: <R, A, B>(fa: Kind3<F, R, E, A>, f: (i: I, a: A) => Option<B>) => Kind3<F, R, E, B>
  readonly filterWithIndex: FilterWithIndex3C<F, I, E>
}

Added in v2.2.0 v2.2.0中添加

FilterableWithIndex4 (interface)
FilterableWithIndex4(接口)

Signature 签名

export interface FilterableWithIndex4<F extends URIS4, I> extends FunctorWithIndex4<F, I>, Filterable4<F> {
  readonly partitionMapWithIndex: <S, R, E, A, B, C>(
    fa: Kind4<F, S, R, E, A>,
    f: (i: I, a: A) => Either<B, C>
  ) => Separated<Kind4<F, S, R, E, B>, Kind4<F, S, R, E, C>>
  readonly partitionWithIndex: PartitionWithIndex4<F, I>
  readonly filterMapWithIndex: <S, R, E, A, B>(
    fa: Kind4<F, S, R, E, A>,
    f: (i: I, a: A) => Option<B>
  ) => Kind4<F, S, R, E, B>
  readonly filterWithIndex: FilterWithIndex4<F, I>
}

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

FilterWithIndex (interface)
带索引的过滤器(接口)

Signature 签名

export interface FilterWithIndex<F, I> {
  <A, B extends A>(fa: HKT<F, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): HKT<F, B>
  <A>(fa: HKT<F, A>, predicateWithIndex: PredicateWithIndex<I, A>): HKT<F, A>
}

Added in v2.0.0 v2.0.0 中添加

FilterWithIndex1 (interface)
FilterWithIndex1(接口)

Signature 签名

export interface FilterWithIndex1<F extends URIS, I> {
  <A, B extends A>(fa: Kind<F, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Kind<F, B>
  <A>(fa: Kind<F, A>, predicateWithIndex: PredicateWithIndex<I, A>): Kind<F, A>
}

Added in v2.0.0 v2.0.0 中添加

FilterWithIndex2 (interface)
FilterWithIndex2(接口)

Signature 签名

export interface FilterWithIndex2<F extends URIS2, I> {
  <E, A, B extends A>(fa: Kind2<F, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Kind2<F, E, B>
  <E, A>(fa: Kind2<F, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Kind2<F, E, A>
}

Added in v2.0.0 v2.0.0 中添加

FilterWithIndex2C (interface)
FilterWithIndex2C(接口)

Signature 签名

export interface FilterWithIndex2C<F extends URIS2, I, E> {
  <A, B extends A>(fa: Kind2<F, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Kind2<F, E, B>
  <A>(fa: Kind2<F, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Kind2<F, E, A>
}

Added in v2.0.0 v2.0.0 中添加

FilterWithIndex3 (interface)
FilterWithIndex3(接口)

Signature 签名

export interface FilterWithIndex3<F extends URIS3, I> {
  <R, E, A, B extends A>(fa: Kind3<F, R, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Kind3<F, R, E, B>
  <R, E, A>(fa: Kind3<F, R, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Kind3<F, R, E, A>
}

Added in v2.0.0 v2.0.0 中添加

FilterWithIndex3C (interface)
FilterWithIndex3C(接口)

Signature 签名

export interface FilterWithIndex3C<F extends URIS3, I, E> {
  <R, A, B extends A>(fa: Kind3<F, R, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Kind3<F, R, E, B>
  <R, A>(fa: Kind3<F, R, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Kind3<F, R, E, A>
}

Added in v2.2.0 v2.2.0中添加

FilterWithIndex4 (interface)
FilterWithIndex4(接口)

Signature 签名

export interface FilterWithIndex4<F extends URIS4, I> {
  <S, R, E, A, B extends A>(fa: Kind4<F, S, R, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Kind4<
    F,
    S,
    R,
    E,
    B
  >
  <S, R, E, A>(fa: Kind4<F, S, R, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Kind4<F, S, R, E, A>
}

Added in v2.0.0 v2.0.0 中添加

PartitionWithIndex (interface)
带索引分区(接口)

Signature 签名

export interface PartitionWithIndex<F, I> {
  <A, B extends A>(fa: HKT<F, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Separated<HKT<F, A>, HKT<F, B>>
  <A>(fa: HKT<F, A>, predicateWithIndex: PredicateWithIndex<I, A>): Separated<HKT<F, A>, HKT<F, A>>
}

Added in v2.0.0 v2.0.0 中添加

PartitionWithIndex1 (interface)
带索引分区1(接口)

Signature 签名

export interface PartitionWithIndex1<F extends URIS, I> {
  <A, B extends A>(fa: Kind<F, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Separated<Kind<F, A>, Kind<F, B>>
  <A>(fa: Kind<F, A>, predicateWithIndex: PredicateWithIndex<I, A>): Separated<Kind<F, A>, Kind<F, A>>
}

Added in v2.0.0 v2.0.0 中添加

PartitionWithIndex2 (interface)
带索引分区2(接口)

Signature 签名

export interface PartitionWithIndex2<F extends URIS2, I> {
  <E, A, B extends A>(fa: Kind2<F, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Separated<
    Kind2<F, E, A>,
    Kind2<F, E, B>
  >
  <E, A>(fa: Kind2<F, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Separated<Kind2<F, E, A>, Kind2<F, E, A>>
}

Added in v2.0.0 v2.0.0 中添加

PartitionWithIndex2C (interface)
PartitionWithIndex2C(接口)

Signature 签名

export interface PartitionWithIndex2C<F extends URIS2, I, E> {
  <A, B extends A>(fa: Kind2<F, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Separated<
    Kind2<F, E, A>,
    Kind2<F, E, B>
  >
  <A>(fa: Kind2<F, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Separated<Kind2<F, E, A>, Kind2<F, E, A>>
}

Added in v2.0.0 v2.0.0 中添加

PartitionWithIndex3 (interface)
带索引分区3(接口)

Signature 签名

export interface PartitionWithIndex3<F extends URIS3, I> {
  <R, E, A, B extends A>(fa: Kind3<F, R, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Separated<
    Kind3<F, R, E, A>,
    Kind3<F, R, E, B>
  >
  <R, E, A>(fa: Kind3<F, R, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Separated<
    Kind3<F, R, E, A>,
    Kind3<F, R, E, A>
  >
}

Added in v2.0.0 v2.0.0 中添加

PartitionWithIndex3C (interface)
PartitionWithIndex3C(接口)

Signature 签名

export interface PartitionWithIndex3C<F extends URIS3, I, E> {
  <R, A, B extends A>(fa: Kind3<F, R, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Separated<
    Kind3<F, R, E, A>,
    Kind3<F, R, E, B>
  >
  <R, A>(fa: Kind3<F, R, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Separated<
    Kind3<F, R, E, A>,
    Kind3<F, R, E, A>
  >
}

Added in v2.2.0 v2.2.0中添加

PartitionWithIndex4 (interface)
带索引分区4(接口)

Signature 签名

export interface PartitionWithIndex4<F extends URIS4, I> {
  <S, R, E, A, B extends A>(fa: Kind4<F, S, R, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Separated<
    Kind4<F, S, R, E, A>,
    Kind4<F, S, R, E, B>
  >
  <S, R, E, A>(fa: Kind4<F, S, R, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Separated<
    Kind4<F, S, R, E, A>,
    Kind4<F, S, R, E, A>
  >
}

Added in v2.0.0 v2.0.0 中添加

PredicateWithIndex (type alias)
PredicateWithIndex(类型别名)

Signature 签名

export type PredicateWithIndex<I, A> = (i: I, a: A) => boolean

Added in v2.0.0 v2.0.0 中添加

RefinementWithIndex (type alias)
RefinementWithIndex(类型别名)

Signature 签名

export type RefinementWithIndex<I, A, B extends A> = (i: I, a: A) => a is B

Added in v2.0.0 v2.0.0 中添加

Foldable overview  可折叠概述

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Foldable (interface)   可折叠(接口)

Signature 签名

export interface Foldable<F> {
  readonly URI: F
  readonly reduce: <A, B>(fa: HKT<F, A>, b: B, f: (b: B, a: A) => B) => B
  readonly foldMap: <M>(M: Monoid<M>) => <A>(fa: HKT<F, A>, f: (a: A) => M) => M
  readonly reduceRight: <A, B>(fa: HKT<F, A>, b: B, f: (a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

Foldable1 (interface)   可折叠1(接口)

Signature 签名

export interface Foldable1<F extends URIS> {
  readonly URI: F
  readonly reduce: <A, B>(fa: Kind<F, A>, b: B, f: (b: B, a: A) => B) => B
  readonly foldMap: <M>(M: Monoid<M>) => <A>(fa: Kind<F, A>, f: (a: A) => M) => M
  readonly reduceRight: <A, B>(fa: Kind<F, A>, b: B, f: (a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

Foldable2 (interface)   可折叠2(接口)

Signature 签名

export interface Foldable2<F extends URIS2> {
  readonly URI: F
  readonly reduce: <E, A, B>(fa: Kind2<F, E, A>, b: B, f: (b: B, a: A) => B) => B
  readonly foldMap: <M>(M: Monoid<M>) => <E, A>(fa: Kind2<F, E, A>, f: (a: A) => M) => M
  readonly reduceRight: <E, A, B>(fa: Kind2<F, E, A>, b: B, f: (a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

Foldable2C (interface)   Foldable2C(接口)

Signature 签名

export interface Foldable2C<F extends URIS2, E> {
  readonly URI: F
  readonly _E: E
  readonly reduce: <A, B>(fa: Kind2<F, E, A>, b: B, f: (b: B, a: A) => B) => B
  readonly foldMap: <M>(M: Monoid<M>) => <A>(fa: Kind2<F, E, A>, f: (a: A) => M) => M
  readonly reduceRight: <A, B>(fa: Kind2<F, E, A>, b: B, f: (a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

Foldable3 (interface)   可折叠3(接口)

Signature 签名

export interface Foldable3<F extends URIS3> {
  readonly URI: F
  readonly reduce: <R, E, A, B>(fa: Kind3<F, R, E, A>, b: B, f: (b: B, a: A) => B) => B
  readonly foldMap: <M>(M: Monoid<M>) => <R, E, A>(fa: Kind3<F, R, E, A>, f: (a: A) => M) => M
  readonly reduceRight: <R, E, A, B>(fa: Kind3<F, R, E, A>, b: B, f: (a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

Foldable3C (interface)   可折叠3C(接口)

Signature 签名

export interface Foldable3C<F extends URIS3, E> {
  readonly URI: F
  readonly _E: E
  readonly reduce: <R, A, B>(fa: Kind3<F, R, E, A>, b: B, f: (b: B, a: A) => B) => B
  readonly foldMap: <M>(M: Monoid<M>) => <R, A>(fa: Kind3<F, R, E, A>, f: (a: A) => M) => M
  readonly reduceRight: <R, A, B>(fa: Kind3<F, R, E, A>, b: B, f: (a: A, b: B) => B) => B
}

Added in v2.2.0 v2.2.0中添加

Foldable4 (interface)   可折叠4(接口)

Signature 签名

export interface Foldable4<F extends URIS4> {
  readonly URI: F
  readonly reduce: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, b: B, f: (b: B, a: A) => B) => B
  readonly foldMap: <M>(M: Monoid<M>) => <S, R, E, A>(fa: Kind4<F, S, R, E, A>, f: (a: A) => M) => M
  readonly reduceRight: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, b: B, f: (a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

foldMap   折叠图

foldMap composition.

Signature 签名

export declare function foldMap<F extends URIS, G extends URIS>(
  F: Foldable1<F>,
  G: Foldable1<G>
): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fga: Kind<F, Kind<G, A>>) => M
export declare function foldMap<F, G>(
  F: Foldable<F>,
  G: Foldable<G>
): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fga: HKT<F, HKT<G, A>>) => M

Added in v2.10.0 v2.10.0 中添加

intercalate  

Fold a data structure, accumulating values in some Monoid, combining adjacent elements using the specified separator
折叠一个数据结构,在一些 Monoid 中累加值,使用指定的分隔符组合相邻元素

Signature 签名

export declare function intercalate<M, F extends URIS3>(
  M: Monoid<M>,
  F: Foldable3<F>
): <R, E>(middle: M, fm: Kind3<F, R, E, M>) => M
export declare function intercalate<M, F extends URIS2>(
  M: Monoid<M>,
  F: Foldable2<F>
): <E>(middle: M, fm: Kind2<F, E, M>) => M
export declare function intercalate<M, F extends URIS2, E>(
  M: Monoid<M>,
  F: Foldable2C<F, E>
): (middle: M, fm: Kind2<F, E, M>) => M
export declare function intercalate<M, F extends URIS>(M: Monoid<M>, F: Foldable1<F>): (middle: M, fm: Kind<F, M>) => M
export declare function intercalate<M, F>(M: Monoid<M>, F: Foldable<F>): (middle: M, fm: HKT<F, M>) => M

Example 例子

import { intercalate } from 'fp-ts/Foldable'
import * as S from 'fp-ts/string'
import { make, Foldable } from 'fp-ts/Tree'

const t = make('a', [make('b', []), make('c', []), make('d', [])])
assert.strictEqual(intercalate(S.Monoid, Foldable)('|', t), 'a|b|c|d')

Added in v2.0.0 v2.0.0 中添加

reduce   减少

reduce composition.

Signature 签名

export declare function reduce<F extends URIS, G extends URIS>(
  F: Foldable1<F>,
  G: Foldable1<G>
): <B, A>(b: B, f: (b: B, a: A) => B) => (fga: Kind<F, Kind<G, A>>) => B
export declare function reduce<F, G>(
  F: Foldable<F>,
  G: Foldable<G>
): <B, A>(b: B, f: (b: B, a: A) => B) => (fga: HKT<F, HKT<G, A>>) => B

Added in v2.10.0 v2.10.0 中添加

reduceM   减少M

Similar to ‘reduce’, but the result is encapsulated in a monad.
与“reduce”类似,但结果封装在一个 monad 中。

Note: this function is not generally stack-safe, e.g., for monads which build up thunks a la IO.
注意:这个函数通常不是堆栈安全的,例如,对于像 IO 那样构建 thunk 的 monad。

Signature 签名

export declare function reduceM<M extends URIS3, F extends URIS>(
  M: Monad3<M>,
  F: Foldable1<F>
): <B, A, R, E>(b: B, f: (b: B, a: A) => Kind3<M, R, E, B>) => (fa: Kind<F, A>) => Kind3<M, R, E, B>
export declare function reduceM<M extends URIS3, F extends URIS, E>(
  M: Monad3C<M, E>,
  F: Foldable1<F>
): <B, A, R>(b: B, f: (b: B, a: A) => Kind3<M, R, E, B>) => (fa: Kind<F, A>) => Kind3<M, R, E, B>
export declare function reduceM<M extends URIS2, F extends URIS>(
  M: Monad2<M>,
  F: Foldable1<F>
): <B, A, E>(b: B, f: (b: B, a: A) => Kind2<M, E, B>) => (fa: Kind<F, A>) => Kind2<M, E, B>
export declare function reduceM<M extends URIS2, F extends URIS, E>(
  M: Monad2C<M, E>,
  F: Foldable1<F>
): <B, A>(b: B, f: (b: B, a: A) => Kind2<M, E, B>) => (fa: Kind<F, A>) => Kind2<M, E, B>
export declare function reduceM<M extends URIS, F extends URIS>(
  M: Monad1<M>,
  F: Foldable1<F>
): <B, A>(b: B, f: (b: B, a: A) => Kind<M, B>) => (fa: Kind<F, A>) => Kind<M, B>
export declare function reduceM<M, F>(
  M: Monad<M>,
  F: Foldable<F>
): <B, A>(b: B, f: (b: B, a: A) => HKT<M, B>) => (fa: HKT<F, A>) => HKT<M, B>

Example 例子

import { reduceM } from 'fp-ts/Foldable'
import { Monad, some } from 'fp-ts/Option'
import { make, Foldable } from 'fp-ts/Tree'
import { pipe } from 'fp-ts/function'

const t = make(1, [make(2, []), make(3, []), make(4, [])])
assert.deepStrictEqual(
  pipe(
    t,
    reduceM(Monad, Foldable)(0, (b, a) => (a > 2 ? some(b + a) : some(b)))
  ),
  some(7)
)

Added in v2.8.0 v2.8.0 中添加

reduceRight   减少右

reduceRight composition.

Signature 签名

export declare function reduceRight<F extends URIS, G extends URIS>(
  F: Foldable1<F>,
  G: Foldable1<G>
): <B, A>(b: B, f: (a: A, b: B) => B) => (fga: Kind<F, Kind<G, A>>) => B
export declare function reduceRight<F, G>(
  F: Foldable<F>,
  G: Foldable<G>
): <B, A>(b: B, f: (a: A, b: B) => B) => (fga: HKT<F, HKT<G, A>>) => B

Added in v2.10.0 v2.10.0 中添加

toReadonlyArray   到只读数组

Transforms a Foldable into a toReadonlyArray.
Foldable 转换为 toReadonlyArray

Signature 签名

export declare function toReadonlyArray<F extends URIS4>(
  F: Foldable4<F>
): <S, R, E, A>(fa: Kind4<F, S, R, E, A>) => ReadonlyArray<A>
export declare function toReadonlyArray<F extends URIS3>(
  F: Foldable3<F>
): <R, E, A>(fa: Kind3<F, R, E, A>) => ReadonlyArray<A>
export declare function toReadonlyArray<F extends URIS3, E>(
  F: Foldable3C<F, E>
): <R, A>(fa: Kind3<F, R, E, A>) => ReadonlyArray<A>
export declare function toReadonlyArray<F extends URIS2>(
  F: Foldable2<F>
): <E, A>(fa: Kind2<F, E, A>) => ReadonlyArray<A>
export declare function toReadonlyArray<F extends URIS2, E>(
  F: Foldable2C<F, E>
): <A>(fa: Kind2<F, E, A>) => ReadonlyArray<A>
export declare function toReadonlyArray<F extends URIS>(F: Foldable1<F>): <A>(fa: Kind<F, A>) => ReadonlyArray<A>
export declare function toReadonlyArray<F>(F: Foldable<F>): <A>(fa: HKT<F, A>) => ReadonlyArray<A>

Example 例子

import { toReadonlyArray } from 'fp-ts/Foldable'
import { Foldable, make } from 'fp-ts/Tree'

const t = make(1, [make(2, []), make(3, []), make(4, [])])
assert.deepStrictEqual(toReadonlyArray(Foldable)(t), [1, 2, 3, 4])

Added in v2.10.0 v2.10.0 中添加

traverse_   遍历_

Traverse a data structure, performing some effects encoded by an Applicative functor at each value, ignoring the final result.
遍历数据结构,对每个值执行由 Applicative 函子编码的一些效果,忽略最终结果。

Signature 签名

export declare function traverse_<M extends URIS3, F extends URIS>(
  M: Applicative3<M>,
  F: Foldable1<F>
): <R, E, A, B>(fa: Kind<F, A>, f: (a: A) => Kind3<M, R, E, B>) => Kind3<M, R, E, void>
export declare function traverse_<M extends URIS2, F extends URIS>(
  M: Applicative2<M>,
  F: Foldable1<F>
): <E, A, B>(fa: Kind<F, A>, f: (a: A) => Kind2<M, E, B>) => Kind2<M, E, void>
export declare function traverse_<M extends URIS2, F extends URIS, E>(
  M: Applicative2C<M, E>,
  F: Foldable1<F>
): <A, B>(fa: Kind<F, A>, f: (a: A) => Kind2<M, E, B>) => Kind2<M, E, void>
export declare function traverse_<M extends URIS, F extends URIS>(
  M: Applicative1<M>,
  F: Foldable1<F>
): <A, B>(fa: Kind<F, A>, f: (a: A) => Kind<M, B>) => Kind<M, void>
export declare function traverse_<M, F>(
  M: Applicative<M>,
  F: Foldable<F>
): <A, B>(fa: HKT<F, A>, f: (a: A) => HKT<M, B>) => HKT<M, void>

Example 例子

import { Foldable } from 'fp-ts/Array'
import { traverse_ } from 'fp-ts/Foldable'
import { Applicative } from 'fp-ts/IO'

let log = ''
const append = (s: string) => () => (log += s)
traverse_(Applicative, Foldable)(['a', 'b', 'c'], append)()
assert.strictEqual(log, 'abc')

Added in v2.0.0 v2.0.0 中添加

zone of death
死亡地带

FoldableComposition11 可折叠组合物11 (interface)   (界面)

Signature 签名

export interface FoldableComposition11<F extends URIS, G extends URIS> {
  readonly reduce: <A, B>(fga: Kind<F, Kind<G, A>>, b: B, f: (b: B, a: A) => B) => B
  readonly foldMap: <M>(M: Monoid<M>) => <A>(fa: Kind<F, Kind<G, A>>, f: (a: A) => M) => M
  readonly reduceRight: <A, B>(fa: Kind<F, Kind<G, A>>, b: B, f: (a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

FoldableComposition12C 可折叠组合物12C (interface)   (界面)

Signature 签名

export interface FoldableComposition12C<F extends URIS, G extends URIS2, E> {
  readonly reduce: <A, B>(fga: Kind<F, Kind2<G, E, A>>, b: B, f: (b: B, a: A) => B) => B
  readonly foldMap: <M>(M: Monoid<M>) => <A>(fa: Kind<F, Kind2<G, E, A>>, f: (a: A) => M) => M
  readonly reduceRight: <A, B>(fa: Kind<F, Kind2<G, E, A>>, b: B, f: (a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

FoldableComposition12 可折叠组合物12 (interface)   (界面)

Signature 签名

export interface FoldableComposition12<F extends URIS, G extends URIS2> {
  readonly reduce: <E, A, B>(fga: Kind<F, Kind2<G, E, A>>, b: B, f: (b: B, a: A) => B) => B
  readonly foldMap: <M>(M: Monoid<M>) => <E, A>(fa: Kind<F, Kind2<G, E, A>>, f: (a: A) => M) => M
  readonly reduceRight: <E, A, B>(fa: Kind<F, Kind2<G, E, A>>, b: B, f: (a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

FoldableComposition21 可折叠组合物21 (interface)   (界面)

Signature 签名

export interface FoldableComposition21<F extends URIS2, G extends URIS> {
  readonly reduce: <E, A, B>(fga: Kind2<F, E, Kind<G, A>>, b: B, f: (b: B, a: A) => B) => B
  readonly foldMap: <M>(M: Monoid<M>) => <E, A>(fa: Kind2<F, E, Kind<G, A>>, f: (a: A) => M) => M
  readonly reduceRight: <E, A, B>(fa: Kind2<F, E, Kind<G, A>>, b: B, f: (a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

FoldableComposition22C 可折叠组合物22C (interface)   (界面)

Signature 签名

export interface FoldableComposition22C<F extends URIS2, G extends URIS2, E> {
  readonly reduce: <FE, A, B>(fga: Kind2<F, FE, Kind2<G, E, A>>, b: B, f: (b: B, a: A) => B) => B
  readonly foldMap: <M>(M: Monoid<M>) => <FE, A>(fa: Kind2<F, FE, Kind2<G, E, A>>, f: (a: A) => M) => M
  readonly reduceRight: <FE, A, B>(fa: Kind2<F, FE, Kind2<G, E, A>>, b: B, f: (a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

FoldableComposition22 可折叠组合物22 (interface)   (界面)

Signature 签名

export interface FoldableComposition22<F extends URIS2, G extends URIS2> {
  readonly reduce: <FE, GE, A, B>(fga: Kind2<F, FE, Kind2<G, GE, A>>, b: B, f: (b: B, a: A) => B) => B
  readonly foldMap: <M>(M: Monoid<M>) => <FE, GE, A>(fa: Kind2<F, FE, Kind2<G, GE, A>>, f: (a: A) => M) => M
  readonly reduceRight: <FE, GE, A, B>(fa: Kind2<F, FE, Kind2<G, GE, A>>, b: B, f: (a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

FoldableComposition2C1 可折叠组合物2C1 (interface)   (界面)

Signature 签名

export interface FoldableComposition2C1<F extends URIS2, G extends URIS, E> {
  readonly reduce: <A, B>(fga: Kind2<F, E, Kind<G, A>>, b: B, f: (b: B, a: A) => B) => B
  readonly foldMap: <M>(M: Monoid<M>) => <A>(fa: Kind2<F, E, Kind<G, A>>, f: (a: A) => M) => M
  readonly reduceRight: <A, B>(fa: Kind2<F, E, Kind<G, A>>, b: B, f: (a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

FoldableComposition 可折叠组合物 (interface)   (界面)

Signature 签名

export interface FoldableComposition<F, G> {
  readonly reduce: <A, B>(fga: HKT<F, HKT<G, A>>, b: B, f: (b: B, a: A) => B) => B
  readonly foldMap: <M>(M: Monoid<M>) => <A>(fa: HKT<F, HKT<G, A>>, f: (a: A) => M) => M
  readonly reduceRight: <A, B>(fa: HKT<F, HKT<G, A>>, b: B, f: (a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

foldM 折叠M

Use reduceM instead 使用 reduceM 代替

Signature 签名

export declare function foldM<M extends URIS3, F extends URIS>(
  M: Monad3<M>,
  F: Foldable1<F>
): <R, E, A, B>(fa: Kind<F, A>, b: B, f: (b: B, a: A) => Kind3<M, R, E, B>) => Kind3<M, R, E, B>
export declare function foldM<M extends URIS3, F extends URIS, E>(
  M: Monad3C<M, E>,
  F: Foldable1<F>
): <R, A, B>(fa: Kind<F, A>, b: B, f: (b: B, a: A) => Kind3<M, R, E, B>) => Kind3<M, R, E, B>
export declare function foldM<M extends URIS2, F extends URIS>(
  M: Monad2<M>,
  F: Foldable1<F>
): <E, A, B>(fa: Kind<F, A>, b: B, f: (b: B, a: A) => Kind2<M, E, B>) => Kind2<M, E, B>
export declare function foldM<M extends URIS2, F extends URIS, E>(
  M: Monad2C<M, E>,
  F: Foldable1<F>
): <A, B>(fa: Kind<F, A>, b: B, f: (b: B, a: A) => Kind2<M, E, B>) => Kind2<M, E, B>
export declare function foldM<M extends URIS, F extends URIS>(
  M: Monad1<M>,
  F: Foldable1<F>
): <A, B>(fa: Kind<F, A>, b: B, f: (b: B, a: A) => Kind<M, B>) => Kind<M, B>
export declare function foldM<M, F>(
  M: Monad<M>,
  F: Foldable<F>
): <A, B>(fa: HKT<F, A>, b: B, f: (b: B, a: A) => HKT<M, B>) => HKT<M, B>

Added in v2.0.0 v2.0.0 中添加

getFoldableComposition 获取可折叠组合

Use 使用

instead.

Signature 签名

export declare function getFoldableComposition<F extends URIS2, G extends URIS2, E>(
  F: Foldable2<F>,
  G: Foldable2C<G, E>
): FoldableComposition22C<F, G, E>
export declare function getFoldableComposition<F extends URIS2, G extends URIS2>(
  F: Foldable2<F>,
  G: Foldable2<G>
): FoldableComposition22<F, G>
export declare function getFoldableComposition<F extends URIS2, G extends URIS, E>(
  F: Foldable2C<F, E>,
  G: Foldable1<G>
): FoldableComposition2C1<F, G, E>
export declare function getFoldableComposition<F extends URIS2, G extends URIS>(
  F: Foldable2<F>,
  G: Foldable1<G>
): FoldableComposition21<F, G>
export declare function getFoldableComposition<F extends URIS, G extends URIS2, E>(
  F: Foldable1<F>,
  G: Foldable2C<G, E>
): FoldableComposition12C<F, G, E>
export declare function getFoldableComposition<F extends URIS, G extends URIS2>(
  F: Foldable1<F>,
  G: Foldable2<G>
): FoldableComposition12<F, G>
export declare function getFoldableComposition<F extends URIS, G extends URIS>(
  F: Foldable1<F>,
  G: Foldable1<G>
): FoldableComposition11<F, G>
export declare function getFoldableComposition<F, G>(F: Foldable<F>, G: Foldable<G>): FoldableComposition<F, G>

Added in v2.0.0 v2.0.0 中添加

toArray 到数组

Use toReadonlyArray instead 使用 toReadonlyArray 代替

Signature 签名

export declare const toArray: typeof toReadonlyArray

Added in v2.8.0 v2.8.0 中添加

FoldableWithIndex overview
FoldableWithIndex 概述

A Foldable with an additional index. A FoldableWithIndex instance must be compatible with its Foldable instance
带有附加索引的 FoldableFoldableWithIndex 实例必须与其 Foldable 实例兼容

reduce(fa, b, f) = reduceWithIndex(fa, b, (_, b, a) => f(b, a))
foldMap(M)(fa, f) = foldMapWithIndex(M)(fa, (_, a) => f(a))
reduceRight(fa, b, f) = reduceRightWithIndex(fa, b, (_, a, b) => f(a, b))

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

FoldableWithIndex (interface)
FoldableWithIndex(接口)

Signature 签名

export interface FoldableWithIndex<F, I> extends Foldable<F> {
  readonly reduceWithIndex: <A, B>(fa: HKT<F, A>, b: B, f: (i: I, b: B, a: A) => B) => B
  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(fa: HKT<F, A>, f: (i: I, a: A) => M) => M
  readonly reduceRightWithIndex: <A, B>(fa: HKT<F, A>, b: B, f: (i: I, a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

FoldableWithIndex1 (interface)
FoldableWithIndex1(接口)

Signature 签名

export interface FoldableWithIndex1<F extends URIS, I> extends Foldable1<F> {
  readonly reduceWithIndex: <A, B>(fa: Kind<F, A>, b: B, f: (i: I, b: B, a: A) => B) => B
  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(fa: Kind<F, A>, f: (i: I, a: A) => M) => M
  readonly reduceRightWithIndex: <A, B>(fa: Kind<F, A>, b: B, f: (i: I, a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

FoldableWithIndex2 (interface)
FoldableWithIndex2(接口)

Signature 签名

export interface FoldableWithIndex2<F extends URIS2, I> extends Foldable2<F> {
  readonly reduceWithIndex: <E, A, B>(fa: Kind2<F, E, A>, b: B, f: (i: I, b: B, a: A) => B) => B
  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <E, A>(fa: Kind2<F, E, A>, f: (i: I, a: A) => M) => M
  readonly reduceRightWithIndex: <E, A, B>(fa: Kind2<F, E, A>, b: B, f: (i: I, a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

FoldableWithIndex2C (interface)
FoldableWithIndex2C(接口)

Signature 签名

export interface FoldableWithIndex2C<F extends URIS2, I, E> extends Foldable2C<F, E> {
  readonly reduceWithIndex: <A, B>(fa: Kind2<F, E, A>, b: B, f: (i: I, b: B, a: A) => B) => B
  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(fa: Kind2<F, E, A>, f: (i: I, a: A) => M) => M
  readonly reduceRightWithIndex: <A, B>(fa: Kind2<F, E, A>, b: B, f: (i: I, a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

FoldableWithIndex3 (interface)
FoldableWithIndex3(接口)

Signature 签名

export interface FoldableWithIndex3<F extends URIS3, I> extends Foldable3<F> {
  readonly reduceWithIndex: <R, E, A, B>(fa: Kind3<F, R, E, A>, b: B, f: (i: I, b: B, a: A) => B) => B
  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <R, E, A>(fa: Kind3<F, R, E, A>, f: (i: I, a: A) => M) => M
  readonly reduceRightWithIndex: <R, E, A, B>(fa: Kind3<F, R, E, A>, b: B, f: (i: I, a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

FoldableWithIndex3C (interface)
FoldableWithIndex3C(接口)

Signature 签名

export interface FoldableWithIndex3C<F extends URIS3, I, E> extends Foldable3C<F, E> {
  readonly reduceWithIndex: <R, A, B>(fa: Kind3<F, R, E, A>, b: B, f: (i: I, b: B, a: A) => B) => B
  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <R, A>(fa: Kind3<F, R, E, A>, f: (i: I, a: A) => M) => M
  readonly reduceRightWithIndex: <R, A, B>(fa: Kind3<F, R, E, A>, b: B, f: (i: I, a: A, b: B) => B) => B
}

Added in v2.2.0 v2.2.0中添加

FoldableWithIndex4 (interface)
FoldableWithIndex4(接口)

Signature 签名

export interface FoldableWithIndex4<F extends URIS4, I> extends Foldable4<F> {
  readonly reduceWithIndex: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, b: B, f: (i: I, b: B, a: A) => B) => B
  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <S, R, E, A>(fa: Kind4<F, S, R, E, A>, f: (i: I, a: A) => M) => M
  readonly reduceRightWithIndex: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, b: B, f: (i: I, a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

foldMapWithIndex   带索引的折叠地图

foldMapWithIndex composition.

Signature 签名

export declare function foldMapWithIndex<F extends URIS, I, G extends URIS, J>(
  F: FoldableWithIndex1<F, I>,
  G: FoldableWithIndex1<G, J>
): <M>(M: Monoid<M>) => <A>(f: (ij: readonly [I, J], a: A) => M) => (fga: Kind<F, Kind<G, A>>) => M
export declare function foldMapWithIndex<F, I, G, J>(
  F: FoldableWithIndex<F, I>,
  G: FoldableWithIndex<G, J>
): <M>(M: Monoid<M>) => <A>(f: (ij: readonly [I, J], a: A) => M) => (fga: HKT<F, HKT<G, A>>) => M

Added in v2.10.0 v2.10.0 中添加

reduceRightWithIndex   减少右索引

reduceRightWithIndex composition.

Signature 签名

export declare function reduceRightWithIndex<F extends URIS, I, G extends URIS, J>(
  F: FoldableWithIndex1<F, I>,
  G: FoldableWithIndex1<G, J>
): <B, A>(b: B, f: (ij: readonly [I, J], a: A, b: B) => B) => (fga: Kind<F, Kind<G, A>>) => B
export declare function reduceRightWithIndex<F, I, G, J>(
  F: FoldableWithIndex<F, I>,
  G: FoldableWithIndex<G, J>
): <B, A>(b: B, f: (ij: readonly [I, J], a: A, b: B) => B) => (fga: HKT<F, HKT<G, A>>) => B

Added in v2.10.0 v2.10.0 中添加

reduceWithIndex  减少索引

reduceWithIndex composition.

Signature 签名

export declare function reduceWithIndex<F extends URIS, I, G extends URIS, J>(
  F: FoldableWithIndex1<F, I>,
  G: FoldableWithIndex1<G, J>
): <B, A>(b: B, f: (ij: readonly [I, J], b: B, a: A) => B) => (fga: Kind<F, Kind<G, A>>) => B
export declare function reduceWithIndex<F, I, G, J>(
  F: FoldableWithIndex<F, I>,
  G: FoldableWithIndex<G, J>
): <B, A>(b: B, f: (ij: readonly [I, J], b: B, a: A) => B) => (fga: HKT<F, HKT<G, A>>) => B

Added in v2.10.0 v2.10.0 中添加

zone of death
死亡地带

FoldableWithIndexComposition11
可折叠带索引组合11
(interface)   (界面)

Signature 签名

export interface FoldableWithIndexComposition11<F extends URIS, FI, G extends URIS, GI>
  extends FoldableComposition11<F, G> {
  readonly reduceWithIndex: <A, B>(fga: Kind<F, Kind<G, A>>, b: B, f: (i: [FI, GI], b: B, a: A) => B) => B
  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(fga: Kind<F, Kind<G, A>>, f: (i: [FI, GI], a: A) => M) => M
  readonly reduceRightWithIndex: <A, B>(fga: Kind<F, Kind<G, A>>, b: B, f: (i: [FI, GI], a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

FoldableWithIndexComposition12C
可折叠带索引组合12C
(interface)   (界面)

Signature 签名

export interface FoldableWithIndexComposition12C<F extends URIS, FI, G extends URIS2, GI, E>
  extends FoldableComposition12C<F, G, E> {
  readonly reduceWithIndex: <A, B>(fga: Kind<F, Kind2<G, E, A>>, b: B, f: (i: [FI, GI], b: B, a: A) => B) => B
  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(fga: Kind<F, Kind2<G, E, A>>, f: (i: [FI, GI], a: A) => M) => M
  readonly reduceRightWithIndex: <A, B>(fga: Kind<F, Kind2<G, E, A>>, b: B, f: (i: [FI, GI], a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

FoldableWithIndexComposition12
可折叠带索引组合12
(interface)   (界面)

Signature 签名

export interface FoldableWithIndexComposition12<F extends URIS, FI, G extends URIS2, GI>
  extends FoldableComposition12<F, G> {
  readonly reduceWithIndex: <E, A, B>(fga: Kind<F, Kind2<G, E, A>>, b: B, f: (i: [FI, GI], b: B, a: A) => B) => B
  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <E, A>(fga: Kind<F, Kind2<G, E, A>>, f: (i: [FI, GI], a: A) => M) => M
  readonly reduceRightWithIndex: <E, A, B>(fga: Kind<F, Kind2<G, E, A>>, b: B, f: (i: [FI, GI], a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

FoldableWithIndexComposition21
FoldableWithIndexComposition21
(interface)   (界面)

Signature 签名

export interface FoldableWithIndexComposition21<F extends URIS2, FI, G extends URIS, GI>
  extends FoldableComposition21<F, G> {
  readonly reduceWithIndex: <FE, A, B>(fga: Kind2<F, FE, Kind<G, A>>, b: B, f: (i: [FI, GI], b: B, a: A) => B) => B
  readonly foldMapWithIndex: <M>(
    M: Monoid<M>
  ) => <FE, A>(fga: Kind2<F, FE, Kind<G, A>>, f: (i: [FI, GI], a: A) => M) => M
  readonly reduceRightWithIndex: <FE, A, B>(fga: Kind2<F, FE, Kind<G, A>>, b: B, f: (i: [FI, GI], a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

FoldableWithIndexComposition22C
可折叠带索引组合22C
(interface)   (界面)

Signature 签名

export interface FoldableWithIndexComposition22C<F extends URIS2, FI, G extends URIS2, GI, E>
  extends FoldableComposition22C<F, G, E> {
  readonly reduceWithIndex: <FE, A, B>(fga: Kind2<F, FE, Kind2<G, E, A>>, b: B, f: (i: [FI, GI], b: B, a: A) => B) => B
  readonly foldMapWithIndex: <M>(
    M: Monoid<M>
  ) => <FE, A>(fga: Kind2<F, FE, Kind2<G, E, A>>, f: (i: [FI, GI], a: A) => M) => M
  readonly reduceRightWithIndex: <FE, A, B>(
    fga: Kind2<F, FE, Kind2<G, E, A>>,
    b: B,
    f: (i: [FI, GI], a: A, b: B) => B
  ) => B
}

Added in v2.0.0 v2.0.0 中添加

FoldableWithIndexComposition22
FoldableWithIndexComposition22
(interface)   (界面)

Signature 签名

export interface FoldableWithIndexComposition22<F extends URIS2, FI, G extends URIS2, GI>
  extends FoldableComposition22<F, G> {
  readonly reduceWithIndex: <FE, GE, A, B>(
    fga: Kind2<F, FE, Kind2<G, GE, A>>,
    b: B,
    f: (i: [FI, GI], b: B, a: A) => B
  ) => B
  readonly foldMapWithIndex: <M>(
    M: Monoid<M>
  ) => <FE, GE, A>(fga: Kind2<F, FE, Kind2<G, GE, A>>, f: (i: [FI, GI], a: A) => M) => M
  readonly reduceRightWithIndex: <FE, GE, A, B>(
    fga: Kind2<F, FE, Kind2<G, GE, A>>,
    b: B,
    f: (i: [FI, GI], a: A, b: B) => B
  ) => B
}

Added in v2.0.0 v2.0.0 中添加

FoldableWithIndexComposition2C1
FoldableWithIndexComposition2C1
(interface)   (界面)

Signature 签名

export interface FoldableWithIndexComposition2C1<F extends URIS2, FI, G extends URIS, GI, FE>
  extends FoldableComposition2C1<F, G, FE> {
  readonly reduceWithIndex: <A, B>(fga: Kind2<F, FE, Kind<G, A>>, b: B, f: (i: [FI, GI], b: B, a: A) => B) => B
  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(fga: Kind2<F, FE, Kind<G, A>>, f: (i: [FI, GI], a: A) => M) => M
  readonly reduceRightWithIndex: <A, B>(fga: Kind2<F, FE, Kind<G, A>>, b: B, f: (i: [FI, GI], a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

FoldableWithIndexComposition
可折叠带索引组合
(interface)   (界面)

Signature 签名

export interface FoldableWithIndexComposition<F, FI, G, GI> extends FoldableComposition<F, G> {
  readonly reduceWithIndex: <A, B>(fga: HKT<F, HKT<G, A>>, b: B, f: (i: [FI, GI], b: B, a: A) => B) => B
  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(fga: HKT<F, HKT<G, A>>, f: (i: [FI, GI], a: A) => M) => M
  readonly reduceRightWithIndex: <A, B>(fga: HKT<F, HKT<G, A>>, b: B, f: (i: [FI, GI], a: A, b: B) => B) => B
}

Added in v2.0.0 v2.0.0 中添加

getFoldableWithIndexComposition
getFoldableWithIndexComposition

Use 使用

instead.

Signature 签名

export declare function getFoldableWithIndexComposition<F extends URIS2, FI, G extends URIS2, GI, E>(
  F: FoldableWithIndex2<F, FI>,
  G: FoldableWithIndex2C<G, GI, E>
): FoldableWithIndexComposition22C<F, FI, G, GI, E>
export declare function getFoldableWithIndexComposition<F extends URIS2, FI, G extends URIS2, GI>(
  F: FoldableWithIndex2<F, FI>,
  G: FoldableWithIndex2<G, GI>
): FoldableWithIndexComposition22<F, FI, G, GI>
export declare function getFoldableWithIndexComposition<F extends URIS2, FI, G extends URIS, GI, E>(
  F: FoldableWithIndex2C<F, FI, E>,
  G: FoldableWithIndex1<G, GI>
): FoldableWithIndexComposition2C1<F, FI, G, GI, E>
export declare function getFoldableWithIndexComposition<F extends URIS2, FI, G extends URIS, GI>(
  F: FoldableWithIndex2<F, FI>,
  G: FoldableWithIndex1<G, GI>
): FoldableWithIndexComposition21<F, FI, G, GI>
export declare function getFoldableWithIndexComposition<F extends URIS, FI, G extends URIS2, GI>(
  F: FoldableWithIndex1<F, FI>,
  G: FoldableWithIndex2<G, GI>
): FoldableWithIndexComposition12<F, FI, G, GI>
export declare function getFoldableWithIndexComposition<F extends URIS, FI, G extends URIS2, GI>(
  F: FoldableWithIndex1<F, FI>,
  G: FoldableWithIndex2<G, GI>
): FoldableWithIndexComposition12<F, FI, G, GI>
export declare function getFoldableWithIndexComposition<F extends URIS, FI, G extends URIS, GI>(
  F: FoldableWithIndex1<F, FI>,
  G: FoldableWithIndex1<G, GI>
): FoldableWithIndexComposition11<F, FI, G, GI>
export declare function getFoldableWithIndexComposition<F, FI, G, GI>(
  F: FoldableWithIndex<F, FI>,
  G: FoldableWithIndex<G, GI>
): FoldableWithIndexComposition<F, FI, G, GI>

Added in v2.0.0 v2.0.0 中添加

FromEither overview  来自任一概述

The FromEither type class represents those data types which support errors.
FromEither 类型类代表那些支持错误的数据类型。

Added in v2.10.0 v2.10.0 中添加


Table of contents
目录


constructors  构造函数

fromOption   来自选项

Signature 签名

export declare function fromOption<F extends URIS4>(
  F: FromEither4<F>
): <E>(onNone: LazyArg<E>) => <A, S, R>(fa: Option<A>) => Kind4<F, S, R, E, A>
export declare function fromOption<F extends URIS3>(
  F: FromEither3<F>
): <E>(onNone: LazyArg<E>) => <A, R>(fa: Option<A>) => Kind3<F, R, E, A>
export declare function fromOption<F extends URIS3, E>(
  F: FromEither3C<F, E>
): (onNone: LazyArg<E>) => <A, R>(fa: Option<A>) => Kind3<F, R, E, A>
export declare function fromOption<F extends URIS2>(
  F: FromEither2<F>
): <E>(onNone: LazyArg<E>) => <A>(fa: Option<A>) => Kind2<F, E, A>
export declare function fromOption<F extends URIS2, E>(
  F: FromEither2C<F, E>
): (onNone: LazyArg<E>) => <A>(fa: Option<A>) => Kind2<F, E, A>
export declare function fromOption<F>(F: FromEither<F>): <E>(onNone: LazyArg<E>) => <A>(ma: Option<A>) => HKT2<F, E, A>

Added in v2.10.0 v2.10.0 中添加

lifting   起重

fromPredicate   来自谓词

Signature 签名

export declare function fromPredicate<F extends URIS4>(
  F: FromEither4<F>
): {
  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <S, R>(a: A) => Kind4<F, S, R, E, B>
  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R, B extends A>(b: B) => Kind4<F, S, R, E, B>
  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R>(a: A) => Kind4<F, S, R, E, A>
}
export declare function fromPredicate<F extends URIS3>(
  F: FromEither3<F>
): {
  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(a: A) => Kind3<F, R, E, B>
  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <R, B extends A>(b: B) => Kind3<F, R, E, B>
  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(a: A) => Kind3<F, R, E, A>
}
export declare function fromPredicate<F extends URIS3, E>(
  F: FromEither3C<F, E>
): {
  <A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(a: A) => Kind3<F, R, E, B>
  <A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R, B extends A>(b: B) => Kind3<F, R, E, B>
  <A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(a: A) => Kind3<F, R, E, A>
}
export declare function fromPredicate<F extends URIS2>(
  F: FromEither2<F>
): {
  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => Kind2<F, E, B>
  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => Kind2<F, E, B>
  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => Kind2<F, E, A>
}
export declare function fromPredicate<F extends URIS2, E>(
  F: FromEither2C<F, E>
): {
  <A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => Kind2<F, E, B>
  <A>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => Kind2<F, E, B>
  <A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => Kind2<F, E, A>
}
export declare function fromPredicate<F>(F: FromEither<F>): {
  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => HKT2<F, E, B>
  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => HKT2<F, E, B>
  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => HKT2<F, E, A>
}

Added in v2.10.0 v2.10.0 中添加

model   模型

FromEither (interface)   FromEither(接口)

Signature 签名

export interface FromEither<F> {
  readonly URI: F
  readonly fromEither: <E, A>(e: Either<E, A>) => HKT2<F, E, A>
}

Added in v2.10.0 v2.10.0 中添加

FromEither1 (interface)
FromEither1(接口)

Signature 签名

export interface FromEither1<F extends URIS> {
  readonly URI: F
  readonly fromEither: <A>(fa: Either<unknown, A>) => Kind<F, A>
}

Added in v2.11.0 v2.11.0 中添加

FromEither2 (interface)
FromEither2(接口)

Signature 签名

export interface FromEither2<F extends URIS2> {
  readonly URI: F
  readonly fromEither: <E, A>(fa: Either<E, A>) => Kind2<F, E, A>
}

Added in v2.10.0 v2.10.0 中添加

FromEither2C (interface)
FromEither2C(接口)

Signature 签名

export interface FromEither2C<F extends URIS2, E> {
  readonly URI: F
  readonly _E: E
  readonly fromEither: <A>(fa: Either<E, A>) => Kind2<F, E, A>
}

Added in v2.10.0 v2.10.0 中添加

FromEither3 (interface)
FromEither3(接口)

Signature 签名

export interface FromEither3<F extends URIS3> {
  readonly URI: F
  readonly fromEither: <E, A, R>(fa: Either<E, A>) => Kind3<F, R, E, A>
}

Added in v2.10.0 v2.10.0 中添加

FromEither3C (interface)
来自Either3C(接口)

Signature 签名

export interface FromEither3C<F extends URIS3, E> {
  readonly URI: F
  readonly _E: E
  readonly fromEither: <A, R>(fa: Either<E, A>) => Kind3<F, R, E, A>
}

Added in v2.10.0 v2.10.0 中添加

FromEither4 (interface)
FromEither4(接口)

Signature 签名

export interface FromEither4<F extends URIS4> {
  readonly URI: F
  readonly fromEither: <E, A, S, R>(fa: Either<E, A>) => Kind4<F, S, R, E, A>
}

Added in v2.10.0 v2.10.0 中添加

utils   实用程序

chainEitherK  链EiK

Signature 签名

export declare function chainEitherK<M extends URIS4>(
  F: FromEither4<M>,
  M: Chain4<M>
): <A, E, B>(f: (a: A) => Either<E, B>) => <S, R>(ma: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, B>
export declare function chainEitherK<M extends URIS3>(
  F: FromEither3<M>,
  M: Chain3<M>
): <A, E, B>(f: (a: A) => Either<E, B>) => <R>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, B>
export declare function chainEitherK<M extends URIS3, E>(
  F: FromEither3C<M, E>,
  M: Chain3C<M, E>
): <A, B>(f: (a: A) => Either<E, B>) => <R>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, B>
export declare function chainEitherK<M extends URIS2>(
  F: FromEither2<M>,
  M: Chain2<M>
): <A, E, B>(f: (a: A) => Either<E, B>) => (ma: Kind2<M, E, A>) => Kind2<M, E, B>
export declare function chainEitherK<M extends URIS2, E>(
  F: FromEither2C<M, E>,
  M: Chain2C<M, E>
): <A, B>(f: (a: A) => Either<E, B>) => (ma: Kind2<M, E, A>) => Kind2<M, E, B>
export declare function chainEitherK<M extends URIS>(
  F: FromEither1<M>,
  M: Chain1<M>
): <E, A, B>(f: (a: A) => Either<E, B>) => (ma: Kind<M, A>) => Kind<M, B>
export declare function chainEitherK<M>(
  F: FromEither<M>,
  M: Chain<M>
): <A, E, B>(f: (a: A) => Either<E, B>) => (ma: HKT2<M, E, A>) => HKT2<M, E, B>

Added in v2.10.0 v2.10.0 中添加

chainFirstEitherK  链FirstEiK

Signature 签名

export declare function chainFirstEitherK<M extends URIS4>(
  F: FromEither4<M>,
  M: Chain4<M>
): <A, E, B>(f: (a: A) => Either<E, B>) => <S, R>(ma: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, A>
export declare function chainFirstEitherK<M extends URIS3>(
  F: FromEither3<M>,
  M: Chain3<M>
): <A, E, B>(f: (a: A) => Either<E, B>) => <R>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, A>
export declare function chainFirstEitherK<M extends URIS3, E>(
  F: FromEither3C<M, E>,
  M: Chain3C<M, E>
): <A, B>(f: (a: A) => Either<E, B>) => <R>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, A>
export declare function chainFirstEitherK<M extends URIS2>(
  F: FromEither2<M>,
  M: Chain2<M>
): <A, E, B>(f: (a: A) => Either<E, B>) => (ma: Kind2<M, E, A>) => Kind2<M, E, A>
export declare function chainFirstEitherK<M extends URIS2, E>(
  F: FromEither2C<M, E>,
  M: Chain2C<M, E>
): <A, B>(f: (a: A) => Either<E, B>) => (ma: Kind2<M, E, A>) => Kind2<M, E, A>
export declare function chainFirstEitherK<M extends URIS>(
  F: FromEither1<M>,
  M: Chain1<M>
): <E, A, B>(f: (a: A) => Either<E, B>) => (ma: Kind<M, A>) => Kind<M, A>
export declare function chainFirstEitherK<M>(
  F: FromEither<M>,
  M: Chain<M>
): <A, E, B>(f: (a: A) => Either<E, B>) => (ma: HKT2<M, E, A>) => HKT2<M, E, A>

Added in v2.12.0 v2.12.0 中添加

chainOptionK   链选项K

Signature 签名

export declare function chainOptionK<F extends URIS4>(
  F: FromEither4<F>,
  M: Chain4<F>
): <E>(onNone: LazyArg<E>) => <A, B>(f: (a: A) => Option<B>) => <S, R>(ma: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>
export declare function chainOptionK<F extends URIS3>(
  F: FromEither3<F>,
  M: Chain3<F>
): <E>(onNone: LazyArg<E>) => <A, B>(f: (a: A) => Option<B>) => <R>(ma: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
export declare function chainOptionK<F extends URIS3, E>(
  F: FromEither3C<F, E>,
  M: Chain3C<F, E>
): (onNone: LazyArg<E>) => <A, B>(f: (a: A) => Option<B>) => <R>(ma: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
export declare function chainOptionK<F extends URIS2>(
  F: FromEither2<F>,
  M: Chain2<F>
): <E>(onNone: LazyArg<E>) => <A, B>(f: (a: A) => Option<B>) => (ma: Kind2<F, E, A>) => Kind2<F, E, B>
export declare function chainOptionK<F extends URIS2, E>(
  F: FromEither2C<F, E>,
  M: Chain2C<F, E>
): (onNone: LazyArg<E>) => <A, B>(f: (a: A) => Option<B>) => (ma: Kind2<F, E, A>) => Kind2<F, E, B>
export declare function chainOptionK<F>(
  F: FromEither<F>,
  M: Chain<F>
): <E>(onNone: LazyArg<E>) => <A, B>(f: (a: A) => Option<B>) => (ma: HKT2<F, E, A>) => HKT2<F, E, B>

Added in v2.10.0 v2.10.0 中添加

filterOrElse  过滤器或者其他

Signature 签名

export declare function filterOrElse<M extends URIS4>(
  F: FromEither4<M>,
  M: Chain4<M>
): {
  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <S, R>(
    ma: Kind4<M, S, R, E, A>
  ) => Kind4<M, S, R, E, B>
  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R, B extends A>(
    mb: Kind4<M, S, R, E, B>
  ) => Kind4<M, S, R, E, B>
  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R>(ma: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, A>
}
export declare function filterOrElse<M extends URIS3>(
  F: FromEither3<M>,
  M: Chain3<M>
): {
  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(
    ma: Kind3<M, R, E, A>
  ) => Kind3<M, R, E, B>
  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <R, B extends A>(mb: Kind3<M, R, E, B>) => Kind3<M, R, E, B>
  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, A>
}
export declare function filterOrElse<M extends URIS3, E>(
  F: FromEither3C<M, E>,
  M: Chain3C<M, E>
): {
  <A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, B>
  <A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R, B extends A>(mb: Kind3<M, R, E, B>) => Kind3<M, R, E, B>
  <A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, A>
}
export declare function filterOrElse<M extends URIS2>(
  F: FromEither2<M>,
  M: Chain2<M>
): {
  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (self: Kind2<M, E, A>) => Kind2<M, E, B>
  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(self: Kind2<M, E, B>) => Kind2<M, E, B>
  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (self: Kind2<M, E, A>) => Kind2<M, E, A>
}
export declare function filterOrElse<M extends URIS2, E>(
  F: FromEither2C<M, E>,
  M: Chain2C<M, E>
): {
  <A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: Kind2<M, E, A>) => Kind2<M, E, B>
  <A>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(mb: Kind2<M, E, B>) => Kind2<M, E, B>
  <A>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: Kind2<M, E, A>) => Kind2<M, E, A>
}
export declare function filterOrElse<M extends URIS2>(
  F: FromEither<M>,
  M: Chain<M>
): {
  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: HKT2<M, E, A>) => HKT2<M, E, B>
  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(mb: HKT2<M, E, B>) => HKT2<M, E, B>
  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: HKT2<M, E, A>) => HKT2<M, E, A>
}

Added in v2.10.0 v2.10.0 中添加

fromEitherK   来自EitherK

Signature 签名

export declare function fromEitherK<F extends URIS4>(
  F: FromEither4<F>
): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => Either<E, B>) => <S, R>(...a: A) => Kind4<F, S, R, E, B>
export declare function fromEitherK<F extends URIS3>(
  F: FromEither3<F>
): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => Either<E, B>) => <R>(...a: A) => Kind3<F, R, E, B>
export declare function fromEitherK<F extends URIS3, E>(
  F: FromEither3C<F, E>
): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Either<E, B>) => <R>(...a: A) => Kind3<F, R, E, B>
export declare function fromEitherK<F extends URIS2>(
  F: FromEither2<F>
): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => Either<E, B>) => (...a: A) => Kind2<F, E, B>
export declare function fromEitherK<F extends URIS2, E>(
  F: FromEither2C<F, E>
): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Either<E, B>) => (...a: A) => Kind2<F, E, B>
export declare function fromEitherK<F extends URIS>(
  F: FromEither1<F>
): <E, A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Either<E, B>) => (...a: A) => Kind<F, B>
export declare function fromEitherK<F>(
  F: FromEither<F>
): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => Either<E, B>) => (...a: A) => HKT2<F, E, B>

Added in v2.10.0 v2.10.0 中添加

fromOptionK   来自选项K

Signature 签名

export declare function fromOptionK<F extends URIS4>(
  F: FromEither4<F>
): <E>(
  onNone: LazyArg<E>
) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => <S, R>(...a: A) => Kind4<F, S, R, E, B>
export declare function fromOptionK<F extends URIS3>(
  F: FromEither3<F>
): <E>(
  onNone: LazyArg<E>
) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => <R>(...a: A) => Kind3<F, R, E, B>
export declare function fromOptionK<F extends URIS3, E>(
  F: FromEither3C<F, E>
): (
  onNone: LazyArg<E>
) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => <R>(...a: A) => Kind3<F, R, E, B>
export declare function fromOptionK<F extends URIS2>(
  F: FromEither2<F>
): <E>(
  onNone: LazyArg<E>
) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => Kind2<F, E, B>
export declare function fromOptionK<F extends URIS2, E>(
  F: FromEither2C<F, E>
): (
  onNone: LazyArg<E>
) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => Kind2<F, E, B>
export declare function fromOptionK<F>(
  F: FromEither<F>
): <E>(
  onNone: LazyArg<E>
) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => HKT2<F, E, B>

Added in v2.10.0 v2.10.0 中添加

FromIO overview  FromIO 概述

Lift a computation from the IO monad
IO monad 提升计算

Added in v2.10.0 v2.10.0 中添加


Table of contents
目录


model   模型

FromIO (interface)   FromIO(接口)

Signature 签名

export interface FromIO<F> {
  readonly URI: F
  readonly fromIO: <A>(fa: IO<A>) => HKT<F, A>
}

Added in v2.10.0 v2.10.0 中添加

FromIO1 (interface)   FromIO1(接口)

Signature 签名

export interface FromIO1<F extends URIS> {
  readonly URI: F
  readonly fromIO: <A>(fa: IO<A>) => Kind<F, A>
}

Added in v2.10.0 v2.10.0 中添加

FromIO2 (interface)   FromIO2(接口)

Signature 签名

export interface FromIO2<F extends URIS2> {
  readonly URI: F
  readonly fromIO: <A, E>(fa: IO<A>) => Kind2<F, E, A>
}

Added in v2.10.0 v2.10.0 中添加

FromIO2C (interface)   来自IO2C(接口)

Signature 签名

export interface FromIO2C<F extends URIS2, E> {
  readonly URI: F
  readonly _E: E
  readonly fromIO: <A>(fa: IO<A>) => Kind2<F, E, A>
}

Added in v2.10.0 v2.10.0 中添加

FromIO3 (interface)   FromIO3(接口)

Signature 签名

export interface FromIO3<F extends URIS3> {
  readonly URI: F
  readonly fromIO: <A, R, E>(fa: IO<A>) => Kind3<F, R, E, A>
}

Added in v2.10.0 v2.10.0 中添加

FromIO3C (interface)   来自IO3C(接口)

Signature 签名

export interface FromIO3C<F extends URIS3, E> {
  readonly URI: F
  readonly _E: E
  readonly fromIO: <A, R>(fa: IO<A>) => Kind3<F, R, E, A>
}

Added in v2.10.0 v2.10.0 中添加

FromIO4 (interface)   来自IO4(接口)

Signature 签名

export interface FromIO4<F extends URIS4> {
  readonly URI: F
  readonly fromIO: <A, S, R, E>(fa: IO<A>) => Kind4<F, S, R, E, A>
}

Added in v2.10.0 v2.10.0 中添加

utils   实用程序

chainFirstIOK  链第一IOK

Signature 签名

export declare function chainFirstIOK<M extends URIS4>(
  F: FromIO4<M>,
  M: Chain4<M>
): <A, B>(f: (a: A) => IO<B>) => <S, R, E>(first: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, A>
export declare function chainFirstIOK<M extends URIS3>(
  F: FromIO3<M>,
  M: Chain3<M>
): <A, B>(f: (a: A) => IO<B>) => <R, E>(first: Kind3<M, R, E, A>) => Kind3<M, R, E, A>
export declare function chainFirstIOK<M extends URIS3, E>(
  F: FromIO3C<M, E>,
  M: Chain3C<M, E>
): <A, B>(f: (a: A) => IO<B>) => <R, E>(first: Kind3<M, R, E, A>) => Kind3<M, R, E, A>
export declare function chainFirstIOK<M extends URIS2>(
  F: FromIO2<M>,
  M: Chain2<M>
): <A, B>(f: (a: A) => IO<B>) => <E>(first: Kind2<M, E, A>) => Kind2<M, E, A>
export declare function chainFirstIOK<M extends URIS2, E>(
  F: FromIO2C<M, E>,
  M: Chain2C<M, E>
): <A, B>(f: (a: A) => IO<B>) => <E>(first: Kind2<M, E, A>) => Kind2<M, E, A>
export declare function chainFirstIOK<M extends URIS>(
  F: FromIO1<M>,
  M: Chain1<M>
): <A, B>(f: (a: A) => IO<B>) => (first: Kind<M, A>) => Kind<M, A>
export declare function chainFirstIOK<M>(
  F: FromIO<M>,
  M: Chain<M>
): <A, B>(f: (a: A) => IO<B>) => (first: HKT<M, A>) => HKT<M, A>

Added in v2.10.0 v2.10.0 中添加

chainIOK  链IOK

Signature 签名

export declare function chainIOK<M extends URIS4>(
  F: FromIO4<M>,
  M: Chain4<M>
): <A, B>(f: (a: A) => IO<B>) => <S, R, E>(first: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, B>
export declare function chainIOK<M extends URIS3>(
  F: FromIO3<M>,
  M: Chain3<M>
): <A, B>(f: (a: A) => IO<B>) => <R, E>(first: Kind3<M, R, E, A>) => Kind3<M, R, E, B>
export declare function chainIOK<M extends URIS3, E>(
  F: FromIO3C<M, E>,
  M: Chain3C<M, E>
): <A, B>(f: (a: A) => IO<B>) => <R>(first: Kind3<M, R, E, A>) => Kind3<M, R, E, B>
export declare function chainIOK<M extends URIS2>(
  F: FromIO2<M>,
  M: Chain2<M>
): <A, B>(f: (a: A) => IO<B>) => <E>(first: Kind2<M, E, A>) => Kind2<M, E, B>
export declare function chainIOK<M extends URIS2, E>(
  F: FromIO2C<M, E>,
  M: Chain2C<M, E>
): <A, B>(f: (a: A) => IO<B>) => (first: Kind2<M, E, A>) => Kind2<M, E, B>
export declare function chainIOK<M extends URIS>(
  F: FromIO1<M>,
  M: Chain1<M>
): <A, B>(f: (a: A) => IO<B>) => (first: Kind<M, A>) => Kind<M, B>
export declare function chainIOK<M>(
  F: FromIO<M>,
  M: Chain<M>
): <A, B>(f: (a: A) => IO<B>) => (first: HKT<M, A>) => HKT<M, B>

Added in v2.10.0 v2.10.0 中添加

fromIOK   来自IOK

Signature 签名

export declare function fromIOK<F extends URIS4>(
  F: FromIO4<F>
): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO<B>) => <S, R, E>(...a: A) => Kind4<F, S, R, E, B>
export declare function fromIOK<F extends URIS3>(
  F: FromIO3<F>
): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO<B>) => <R, E>(...a: A) => Kind3<F, R, E, B>
export declare function fromIOK<F extends URIS3, E>(
  F: FromIO3C<F, E>
): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO<B>) => <R>(...a: A) => Kind3<F, R, E, B>
export declare function fromIOK<F extends URIS2>(
  F: FromIO2<F>
): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO<B>) => <E>(...a: A) => Kind2<F, E, B>
export declare function fromIOK<F extends URIS2, E>(
  F: FromIO2C<F, E>
): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO<B>) => (...a: A) => Kind2<F, E, B>
export declare function fromIOK<F extends URIS>(
  F: FromIO1<F>
): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO<B>) => (...a: A) => Kind<F, B>
export declare function fromIOK<F>(
  F: FromIO<F>
): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO<B>) => (...a: A) => HKT<F, B>

Added in v2.10.0 v2.10.0 中添加

FromReader overview  FromReader 概述

Lift a computation from the Reader monad.
Reader monad 提升计算。

Added in v2.11.0 v2.11.0 中添加


Table of contents
目录


constructors  构造函数

ask  

Signature 签名

export declare function ask<F extends URIS4>(F: FromReader4<F>): <S, R, E>() => Kind4<F, S, R, E, R>
export declare function ask<F extends URIS3>(F: FromReader3<F>): <R, E>() => Kind3<F, R, E, R>
export declare function ask<F extends URIS3, E>(F: FromReader3C<F, E>): <R>() => Kind3<F, R, E, R>
export declare function ask<F extends URIS2>(F: FromReader2<F>): <R>() => Kind2<F, R, R>
export declare function ask<F>(F: FromReader<F>): <R>() => HKT2<F, R, R>

Added in v2.11.0 v2.11.0 中添加

asks  

Signature 签名

export declare function asks<F extends URIS4>(F: FromReader4<F>): <R, A, S, E>(f: (r: R) => A) => Kind4<F, S, R, E, A>
export declare function asks<F extends URIS3>(F: FromReader3<F>): <R, A, E>(f: (r: R) => A) => Kind3<F, R, E, A>
export declare function asks<F extends URIS3, E>(F: FromReader3C<F, E>): <R, A>(f: (r: R) => A) => Kind3<F, R, E, A>
export declare function asks<F extends URIS2>(F: FromReader2<F>): <R, A>(f: (r: R) => A) => Kind2<F, R, A>
export declare function asks<F>(F: FromReader<F>): <R, A>(f: (r: R) => A) => HKT2<F, R, A>

Added in v2.11.0 v2.11.0 中添加

model   模型

FromReader (interface)   FromReader(接口)

Signature 签名

export interface FromReader<F> {
  readonly URI: F
  readonly fromReader: <R, A>(fa: Reader<R, A>) => HKT2<F, R, A>
}

Added in v2.11.0 v2.11.0 中添加

FromReader2 (interface)
FromReader2(接口)

Signature 签名

export interface FromReader2<F extends URIS2> {
  readonly URI: F
  readonly fromReader: <E, A>(fa: Reader<E, A>) => Kind2<F, E, A>
}

Added in v2.11.0 v2.11.0 中添加

FromReader3 (interface)
FromReader3(接口)

Signature 签名

export interface FromReader3<F extends URIS3> {
  readonly URI: F
  readonly fromReader: <R, A, E>(fa: Reader<R, A>) => Kind3<F, R, E, A>
}

Added in v2.11.0 v2.11.0 中添加

FromReader3C (interface)
FromReader3C(接口)

Signature 签名

export interface FromReader3C<F extends URIS3, E> {
  readonly URI: F
  readonly _E: E
  readonly fromReader: <R, A>(fa: Reader<R, A>) => Kind3<F, R, E, A>
}

Added in v2.11.0 v2.11.0 中添加

FromReader4 (interface)
FromReader4(接口)

Signature 签名

export interface FromReader4<F extends URIS4> {
  readonly URI: F
  readonly fromReader: <R, A, S, E>(fa: Reader<R, A>) => Kind4<F, S, R, E, A>
}

Added in v2.11.0 v2.11.0 中添加

utils   实用程序

chainFirstReaderK  链第一读者K

Signature 签名

export declare function chainFirstReaderK<M extends URIS4>(
  F: FromReader4<M>,
  M: Chain4<M>
): <A, R, B>(f: (a: A) => Reader<R, B>) => <S, E>(ma: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, A>
export declare function chainFirstReaderK<M extends URIS3>(
  F: FromReader3<M>,
  M: Chain3<M>
): <A, R, B>(f: (a: A) => Reader<R, B>) => <E>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, A>
export declare function chainFirstReaderK<M extends URIS3, E>(
  F: FromReader3C<M, E>,
  M: Chain3C<M, E>
): <A, R, B>(f: (a: A) => Reader<R, B>) => (ma: Kind3<M, R, E, A>) => Kind3<M, R, E, A>
export declare function chainFirstReaderK<M extends URIS2>(
  F: FromReader2<M>,
  M: Chain2<M>
): <A, R, B>(f: (a: A) => Reader<R, B>) => (ma: Kind2<M, R, A>) => Kind2<M, R, A>
export declare function chainFirstReaderK<M>(
  F: FromReader<M>,
  M: Chain<M>
): <A, R, B>(f: (a: A) => Reader<R, B>) => (ma: HKT2<M, R, A>) => HKT2<M, R, A>

Added in v2.11.0 v2.11.0 中添加

chainReaderK  链读器K

Signature 签名

export declare function chainReaderK<M extends URIS4>(
  F: FromReader4<M>,
  M: Chain4<M>
): <A, R, B>(f: (a: A) => Reader<R, B>) => <S, E>(ma: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, B>
export declare function chainReaderK<M extends URIS3>(
  F: FromReader3<M>,
  M: Chain3<M>
): <A, R, B>(f: (a: A) => Reader<R, B>) => <E>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, B>
export declare function chainReaderK<M extends URIS3, E>(
  F: FromReader3C<M, E>,
  M: Chain3C<M, E>
): <A, R, B>(f: (a: A) => Reader<R, B>) => (ma: Kind3<M, R, E, A>) => Kind3<M, R, E, B>
export declare function chainReaderK<M extends URIS2>(
  F: FromReader2<M>,
  M: Chain2<M>
): <A, R, B>(f: (a: A) => Reader<R, B>) => (ma: Kind2<M, R, A>) => Kind2<M, R, B>
export declare function chainReaderK<M>(
  F: FromReader<M>,
  M: Chain<M>
): <A, R, B>(f: (a: A) => Reader<R, B>) => (ma: HKT2<M, R, A>) => HKT2<M, R, B>

Added in v2.11.0 v2.11.0 中添加

fromReaderK   来自ReaderK

Signature 签名

export declare function fromReaderK<F extends URIS4>(
  F: FromReader4<F>
): <A extends ReadonlyArray<unknown>, R, B>(f: (...a: A) => Reader<R, B>) => <S, E>(...a: A) => Kind4<F, S, R, E, B>
export declare function fromReaderK<F extends URIS3>(
  F: FromReader3<F>
): <A extends ReadonlyArray<unknown>, R, B>(f: (...a: A) => Reader<R, B>) => <E>(...a: A) => Kind3<F, R, E, B>
export declare function fromReaderK<F extends URIS3, E>(
  F: FromReader3C<F, E>
): <A extends ReadonlyArray<unknown>, R, B>(f: (...a: A) => Reader<R, B>) => (...a: A) => Kind3<F, R, E, B>
export declare function fromReaderK<F extends URIS2>(
  F: FromReader2<F>
): <A extends ReadonlyArray<unknown>, R, B>(f: (...a: A) => Reader<R, B>) => (...a: A) => Kind2<F, R, B>
export declare function fromReaderK<F>(
  F: FromReader<F>
): <A extends ReadonlyArray<unknown>, R, B>(f: (...a: A) => Reader<R, B>) => (...a: A) => HKT2<F, R, B>

Added in v2.11.0 v2.11.0 中添加

FromState overview  FromState 概述

Lift a computation from the State monad.
State monad 提升计算。

Added in v2.11.0 v2.11.0 中添加


Table of contents
目录


constructors  构造函数

get   得到

Signature 签名

export declare function get<F extends URIS4>(F: FromState4<F>): <S, R, E>() => Kind4<F, S, R, E, S>
export declare function get<F extends URIS3>(F: FromState3<F>): <S, E>() => Kind3<F, S, E, S>
export declare function get<F extends URIS3, E>(F: FromState3C<F, E>): <S>() => Kind3<F, S, E, S>
export declare function get<F extends URIS2>(F: FromState2<F>): <S>() => Kind2<F, S, S>
export declare function get<F>(F: FromState<F>): <S>() => HKT2<F, S, S>

Added in v2.11.0 v2.11.0 中添加

gets   得到

Signature 签名

export declare function gets<F extends URIS4>(F: FromState4<F>): <S, R, E, A>(f: (s: S) => A) => Kind4<F, S, R, E, A>
export declare function gets<F extends URIS3>(F: FromState3<F>): <S, E, A>(f: (s: S) => A) => Kind3<F, S, E, A>
export declare function gets<F extends URIS3, E>(F: FromState3C<F, E>): <S, A>(f: (s: S) => A) => Kind3<F, S, E, A>
export declare function gets<F extends URIS2>(F: FromState2<F>): <S, A>(f: (s: S) => A) => Kind2<F, S, A>
export declare function gets<F>(F: FromState<F>): <S, A>(f: (s: S) => A) => HKT2<F, S, A>

Added in v2.11.0 v2.11.0 中添加

modify   调整

Signature 签名

export declare function modify<F extends URIS4>(
  F: FromState4<F>
): <S, R, E>(f: Endomorphism<S>) => Kind4<F, S, R, E, void>
export declare function modify<F extends URIS3>(F: FromState3<F>): <S, E>(f: Endomorphism<S>) => Kind3<F, S, E, void>
export declare function modify<F extends URIS3, E>(
  F: FromState3C<F, E>
): <S>(f: Endomorphism<S>) => Kind3<F, S, E, void>
export declare function modify<F extends URIS2>(F: FromState2<F>): <S>(f: Endomorphism<S>) => Kind2<F, S, void>
export declare function modify<F>(F: FromState<F>): <S>(f: Endomorphism<S>) => HKT2<F, S, void>

Added in v2.11.0 v2.11.0 中添加

put  

Signature 签名

export declare function put<F extends URIS4>(F: FromState4<F>): <S, R, E>(s: S) => Kind4<F, S, R, E, void>
export declare function put<F extends URIS3>(F: FromState3<F>): <S, E>(s: S) => Kind3<F, S, E, void>
export declare function put<F extends URIS3, E>(F: FromState3C<F, E>): <S>(s: S) => Kind3<F, S, E, void>
export declare function put<F extends URIS2>(F: FromState2<F>): <S>(s: S) => Kind2<F, S, void>
export declare function put<F>(F: FromState<F>): <S>(s: S) => HKT2<F, S, void>

Added in v2.11.0 v2.11.0 中添加

model   模型

FromState (interface)   从状态(接口)

Signature 签名

export interface FromState<F> {
  readonly URI: F
  readonly fromState: <S, A>(fa: State<S, A>) => HKT2<F, S, A>
}

Added in v2.11.0 v2.11.0 中添加

FromState2 (interface)   FromState2(接口)

Signature 签名

export interface FromState2<F extends URIS2> {
  readonly URI: F
  readonly fromState: <S, A>(fa: State<S, A>) => Kind2<F, S, A>
}

Added in v2.11.0 v2.11.0 中添加

FromState3 (interface)   FromState3(接口)

Signature 签名

export interface FromState3<F extends URIS3> {
  readonly URI: F
  readonly fromState: <S, A, E>(fa: State<S, A>) => Kind3<F, S, E, A>
}

Added in v2.11.0 v2.11.0 中添加

FromState3C (interface)
FromState3C(接口)

Signature 签名

export interface FromState3C<F extends URIS3, E> {
  readonly URI: F
  readonly _E: E
  readonly fromState: <S, A>(fa: State<S, A>) => Kind3<F, S, E, A>
}

Added in v2.11.0 v2.11.0 中添加

FromState4 (interface)   FromState4(接口)

Signature 签名

export interface FromState4<F extends URIS4> {
  readonly URI: F
  readonly fromState: <S, A, R, E>(fa: State<S, A>) => Kind4<F, S, R, E, A>
}

Added in v2.11.0 v2.11.0 中添加

utils   实用程序

chainStateK   链状态K

Signature 签名

export declare function chainStateK<M extends URIS4>(
  F: FromState4<M>,
  M: Chain4<M>
): <A, S, B>(f: (a: A) => State<S, B>) => <R, E>(ma: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, B>
export declare function chainStateK<M extends URIS3>(
  F: FromState3<M>,
  M: Chain3<M>
): <A, S, B>(f: (a: A) => State<S, B>) => <E>(ma: Kind3<M, S, E, A>) => Kind3<M, S, E, B>
export declare function chainStateK<M extends URIS2>(
  F: FromState2<M>,
  M: Chain2<M>
): <A, S, B>(f: (a: A) => State<S, B>) => (ma: Kind2<M, S, A>) => Kind2<M, S, B>
export declare function chainStateK<M>(
  F: FromState<M>,
  M: Chain<M>
): <A, S, B>(f: (a: A) => State<S, B>) => (ma: HKT2<M, S, A>) => HKT2<M, S, B>

Added in v2.11.0 v2.11.0 中添加

fromStateK   来自K州

Signature 签名

export declare function fromStateK<F extends URIS4>(
  F: FromState4<F>
): <A extends ReadonlyArray<unknown>, S, B>(f: (...a: A) => State<S, B>) => <R, E>(...a: A) => Kind4<F, S, R, E, B>
export declare function fromStateK<F extends URIS3>(
  F: FromState3<F>
): <A extends ReadonlyArray<unknown>, S, B>(f: (...a: A) => State<S, B>) => <E>(...a: A) => Kind3<F, S, E, B>
export declare function fromStateK<F extends URIS3, E>(
  F: FromState3C<F, E>
): <A extends ReadonlyArray<unknown>, S, B>(f: (...a: A) => State<S, B>) => (...a: A) => Kind3<F, S, E, B>
export declare function fromStateK<F extends URIS2>(
  F: FromState2<F>
): <A extends ReadonlyArray<unknown>, S, B>(f: (...a: A) => State<S, B>) => (...a: A) => Kind2<F, S, B>
export declare function fromStateK<F>(
  F: FromState<F>
): <A extends ReadonlyArray<unknown>, S, B>(f: (...a: A) => State<S, B>) => (...a: A) => HKT2<F, S, B>

Added in v2.11.0 v2.11.0 中添加

FromTask overview  FromTask 概述

Lift a computation from the Task monad
Task monad 提升计算

Added in v2.10.0 v2.10.0 中添加


Table of contents
目录


model   模型

FromTask (interface)   FromTask(接口)

Signature 签名

export interface FromTask<F> extends FromIO<F> {
  readonly fromTask: <A>(fa: Task<A>) => HKT<F, A>
}

Added in v2.10.0 v2.10.0 中添加

FromTask1 (interface)   FromTask1(接口)

Signature 签名

export interface FromTask1<F extends URIS> extends FromIO1<F> {
  readonly fromTask: <A>(fa: Task<A>) => Kind<F, A>
}

Added in v2.10.0 v2.10.0 中添加

FromTask2 (interface)   FromTask2(接口)

Signature 签名

export interface FromTask2<F extends URIS2> extends FromIO2<F> {
  readonly fromTask: <A, E>(fa: Task<A>) => Kind2<F, E, A>
}

Added in v2.10.0 v2.10.0 中添加

FromTask2C (interface)   FromTask2C(接口)

Signature 签名

export interface FromTask2C<F extends URIS2, E> extends FromIO2C<F, E> {
  readonly fromTask: <A>(fa: Task<A>) => Kind2<F, E, A>
}

Added in v2.10.0 v2.10.0 中添加

FromTask3 (interface)   FromTask3(接口)

Signature 签名

export interface FromTask3<F extends URIS3> extends FromIO3<F> {
  readonly fromTask: <A, R, E>(fa: Task<A>) => Kind3<F, R, E, A>
}

Added in v2.10.0 v2.10.0 中添加

FromTask3C (interface)   FromTask3C(接口)

Signature 签名

export interface FromTask3C<F extends URIS3, E> extends FromIO3C<F, E> {
  readonly fromTask: <A, R>(fa: Task<A>) => Kind3<F, R, E, A>
}

Added in v2.10.0 v2.10.0 中添加

FromTask4 (interface)   FromTask4(接口)

Signature 签名

export interface FromTask4<F extends URIS4> extends FromIO4<F> {
  readonly fromTask: <A, S, R, E>(fa: Task<A>) => Kind4<F, S, R, E, A>
}

Added in v2.10.0 v2.10.0 中添加

utils   实用程序

chainFirstTaskK  链第一任务K

Signature 签名

export declare function chainFirstTaskK<M extends URIS4>(
  F: FromTask4<M>,
  M: Chain4<M>
): <A, B>(f: (a: A) => Task<B>) => <S, R, E>(first: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, A>
export declare function chainFirstTaskK<M extends URIS3>(
  F: FromTask3<M>,
  M: Chain3<M>
): <A, B>(f: (a: A) => Task<B>) => <R, E>(first: Kind3<M, R, E, A>) => Kind3<M, R, E, A>
export declare function chainFirstTaskK<M extends URIS3, E>(
  F: FromTask3C<M, E>,
  M: Chain3C<M, E>
): <A, B>(f: (a: A) => Task<B>) => <R>(first: Kind3<M, R, E, A>) => Kind3<M, R, E, A>
export declare function chainFirstTaskK<M extends URIS2>(
  F: FromTask2<M>,
  M: Chain2<M>
): <A, B>(f: (a: A) => Task<B>) => <E>(first: Kind2<M, E, A>) => Kind2<M, E, A>
export declare function chainFirstTaskK<M extends URIS2, E>(
  F: FromTask2C<M, E>,
  M: Chain2C<M, E>
): <A, B>(f: (a: A) => Task<B>) => (first: Kind2<M, E, A>) => Kind2<M, E, A>
export declare function chainFirstTaskK<M extends URIS>(
  F: FromTask1<M>,
  M: Chain1<M>
): <A, B>(f: (a: A) => Task<B>) => (first: Kind<M, A>) => Kind<M, A>
export declare function chainFirstTaskK<M>(
  F: FromTask<M>,
  M: Chain<M>
): <A, B>(f: (a: A) => Task<B>) => (first: HKT<M, A>) => HKT<M, A>

Added in v2.10.0 v2.10.0 中添加

chainTaskK  链任务K

Signature 签名

export declare function chainTaskK<M extends URIS4>(
  F: FromTask4<M>,
  M: Chain4<M>
): <A, B>(f: (a: A) => Task<B>) => <S, R, E>(first: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, B>
export declare function chainTaskK<M extends URIS3>(
  F: FromTask3<M>,
  M: Chain3<M>
): <A, B>(f: (a: A) => Task<B>) => <R, E>(first: Kind3<M, R, E, A>) => Kind3<M, R, E, B>
export declare function chainTaskK<M extends URIS3, E>(
  F: FromTask3C<M, E>,
  M: Chain3C<M, E>
): <A, B>(f: (a: A) => Task<B>) => <R>(first: Kind3<M, R, E, A>) => Kind3<M, R, E, B>
export declare function chainTaskK<M extends URIS2>(
  F: FromTask2<M>,
  M: Chain2<M>
): <A, B>(f: (a: A) => Task<B>) => <E>(first: Kind2<M, E, A>) => Kind2<M, E, B>
export declare function chainTaskK<M extends URIS2, E>(
  F: FromTask2C<M, E>,
  M: Chain2C<M, E>
): <A, B>(f: (a: A) => Task<B>) => (first: Kind2<M, E, A>) => Kind2<M, E, B>
export declare function chainTaskK<M extends URIS>(
  F: FromTask1<M>,
  M: Chain1<M>
): <A, B>(f: (a: A) => Task<B>) => (first: Kind<M, A>) => Kind<M, B>
export declare function chainTaskK<M>(
  F: FromTask<M>,
  M: Chain<M>
): <A, B>(f: (a: A) => Task<B>) => (first: HKT<M, A>) => HKT<M, B>

Added in v2.10.0 v2.10.0 中添加

fromTaskK   来自任务K

Signature 签名

export declare function fromTaskK<F extends URIS4>(
  F: FromTask4<F>
): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Task<B>) => <S, R, E>(...a: A) => Kind4<F, S, R, E, B>
export declare function fromTaskK<F extends URIS3>(
  F: FromTask3<F>
): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Task<B>) => <R, E>(...a: A) => Kind3<F, R, E, B>
export declare function fromTaskK<F extends URIS3, E>(
  F: FromTask3C<F, E>
): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Task<B>) => <R>(...a: A) => Kind3<F, R, E, B>
export declare function fromTaskK<F extends URIS2>(
  F: FromTask2<F>
): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Task<B>) => <E>(...a: A) => Kind2<F, E, B>
export declare function fromTaskK<F extends URIS2, E>(
  F: FromTask2C<F, E>
): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Task<B>) => (...a: A) => Kind2<F, E, B>
export declare function fromTaskK<F extends URIS>(
  F: FromTask1<F>
): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Task<B>) => (...a: A) => Kind<F, B>
export declare function fromTaskK<F>(
  F: FromTask<F>
): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Task<B>) => (...a: A) => HKT<F, B>

Added in v2.10.0 v2.10.0 中添加

FromThese overview  来自这些概述

The FromThese type class represents those data types which support errors and warnings.
FromThese 类型类表示支持错误和警告的数据类型。

Added in v2.11.0 v2.11.0 中添加


Table of contents
目录


model   模型

FromThese (interface)  来自这些(界面)

Signature 签名

export interface FromThese<F> {
  readonly URI: F
  readonly fromThese: <E, A>(e: These<E, A>) => HKT2<F, E, A>
}

Added in v2.11.0 v2.11.0 中添加

FromThese2 (interface)   FromThese2(接口)

Signature 签名

export interface FromThese2<F extends URIS2> {
  readonly URI: F
  readonly fromThese: <E, A>(fa: These<E, A>) => Kind2<F, E, A>
}

Added in v2.11.0 v2.11.0 中添加

FromThese2C (interface)
FromThese2C(接口)

Signature 签名

export interface FromThese2C<F extends URIS2, E> {
  readonly URI: F
  readonly _E: E
  readonly fromThese: <A>(fa: These<E, A>) => Kind2<F, E, A>
}

Added in v2.11.0 v2.11.0 中添加

FromThese3 (interface)   FromThese3(接口)

Signature 签名

export interface FromThese3<F extends URIS3> {
  readonly URI: F
  readonly fromThese: <E, A, R>(fa: These<E, A>) => Kind3<F, R, E, A>
}

Added in v2.11.0 v2.11.0 中添加

FromThese3C (interface)
FromThese3C(接口)

Signature 签名

export interface FromThese3C<F extends URIS3, E> {
  readonly URI: F
  readonly _E: E
  readonly fromThese: <A, R>(fa: These<E, A>) => Kind3<F, R, E, A>
}

Added in v2.11.0 v2.11.0 中添加

FromThese4 (interface)   FromThese4(接口)

Signature 签名

export interface FromThese4<F extends URIS4> {
  readonly URI: F
  readonly fromThese: <E, A, S, R>(fa: These<E, A>) => Kind4<F, S, R, E, A>
}

Added in v2.11.0 v2.11.0 中添加

utils   实用程序

fromTheseK  来自这些K

Signature 签名

export declare function fromTheseK<F extends URIS4>(
  F: FromThese4<F>
): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => These<E, B>) => <S, R>(...a: A) => Kind4<F, S, R, E, B>
export declare function fromTheseK<F extends URIS3>(
  F: FromThese3<F>
): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => These<E, B>) => <R>(...a: A) => Kind3<F, R, E, B>
export declare function fromTheseK<F extends URIS3, E>(
  F: FromThese3C<F, E>
): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => These<E, B>) => <R>(...a: A) => Kind3<F, R, E, B>
export declare function fromTheseK<F extends URIS2>(
  F: FromThese2<F>
): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => These<E, B>) => (...a: A) => Kind2<F, E, B>
export declare function fromTheseK<F extends URIS2, E>(
  F: FromThese2C<F, E>
): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => These<E, B>) => (...a: A) => Kind2<F, E, B>
export declare function fromTheseK<F>(
  F: FromThese<F>
): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => These<E, B>) => (...a: A) => HKT2<F, E, B>

Added in v2.11.0 v2.11.0 中添加

function overview  功能概述

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


instances   实例

getBooleanAlgebra   获取布尔代数

Signature 签名

export declare const getBooleanAlgebra: <B>(B: BooleanAlgebra<B>) => <A = never>() => BooleanAlgebra<(a: A) => B>

Added in v2.10.0 v2.10.0 中添加

getMonoid   获取Monoid

Unary functions form a monoid as long as you can provide a monoid for the codomain.
只要您能为余域提供一个幺半群,一元函数就可以形成一个幺半群。

Signature 签名

export declare const getMonoid: <M>(M: Monoid<M>) => <A = never>() => Monoid<(a: A) => M>

Example 例子

import { Predicate } from 'fp-ts/Predicate'
import { getMonoid } from 'fp-ts/function'
import * as B from 'fp-ts/boolean'

const f: Predicate<number> = (n) => n <= 2
const g: Predicate<number> = (n) => n >= 0

const M1 = getMonoid(B.MonoidAll)<number>()

assert.deepStrictEqual(M1.concat(f, g)(1), true)
assert.deepStrictEqual(M1.concat(f, g)(3), false)

const M2 = getMonoid(B.MonoidAny)<number>()

assert.deepStrictEqual(M2.concat(f, g)(1), true)
assert.deepStrictEqual(M2.concat(f, g)(3), true)

Added in v2.10.0 v2.10.0 中添加

getRing   获取铃声

Signature 签名

export declare const getRing: <A, B>(R: Ring<B>) => Ring<(a: A) => B>

Added in v2.10.0 v2.10.0 中添加

getSemigroup   获取半群

Unary functions form a semigroup as long as you can provide a semigroup for the codomain.
只要您能为余域提供半群,一元函数就可以形成半群。

Signature 签名

export declare const getSemigroup: <S>(S: Semigroup<S>) => <A = never>() => Semigroup<(a: A) => S>

Example 例子

import { Predicate, getSemigroup } from 'fp-ts/function'
import * as B from 'fp-ts/boolean'

const f: Predicate<number> = (n) => n <= 2
const g: Predicate<number> = (n) => n >= 0

const S1 = getSemigroup(B.SemigroupAll)<number>()

assert.deepStrictEqual(S1.concat(f, g)(1), true)
assert.deepStrictEqual(S1.concat(f, g)(3), false)

const S2 = getSemigroup(B.SemigroupAny)<number>()

assert.deepStrictEqual(S2.concat(f, g)(1), true)
assert.deepStrictEqual(S2.concat(f, g)(3), true)

Added in v2.10.0 v2.10.0 中添加

getSemiring   获取Semiring

Signature 签名

export declare const getSemiring: <A, B>(S: Semiring<B>) => Semiring<(a: A) => B>

Added in v2.10.0 v2.10.0 中添加

lagacy   落后

Lazy (interface)   懒惰(接口)

Use LazyArg instead. 请改用 LazyArg

Signature 签名

export interface Lazy<A> {
  (): A
}

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

FunctionN (interface)   功能N(接口)

Signature 签名

export interface FunctionN<A extends ReadonlyArray<unknown>, B> {
  (...args: A): B
}

Example 例子

import { FunctionN } from 'fp-ts/function'

export const sum: FunctionN<[number, number], number> = (a, b) => a + b

Added in v2.0.0 v2.0.0 中添加

LazyArg (interface)   LazyArg(接口)

A lazy argument. 一个懒惰的论点。

Signature 签名

export interface LazyArg<A> {
  (): A
}

Added in v2.15.0 v2.15.0 中添加

SK   SK

Signature 签名

export declare const SK: <A, B>(_: A, b: B) => B

Added in v2.11.0 v2.11.0 中添加

absurd   荒诞

Signature 签名

export declare function absurd<A>(_: never): A

Added in v2.0.0 v2.0.0 中添加

apply   申请

Signature 签名

export declare const apply: <A>(a: A) => <B>(f: (a: A) => B) => B

Added in v2.11.0 v2.11.0 中添加

constFalse   常量假

A thunk that returns always false.
始终返回 false 的 thunk。

Signature 签名

export declare const constFalse: LazyArg<boolean>

Added in v2.0.0 v2.0.0 中添加

constNull   常量空值

A thunk that returns always null.
始终返回 null 的 thunk。

Signature 签名

export declare const constNull: LazyArg<null>

Added in v2.0.0 v2.0.0 中添加

constTrue   常量真

A thunk that returns always true.
始终返回 true 的 thunk。

Signature 签名

export declare const constTrue: LazyArg<boolean>

Added in v2.0.0 v2.0.0 中添加

constUndefined   常量未定义

A thunk that returns always undefined.
始终返回 undefined 的 thunk。

Signature 签名

export declare const constUndefined: LazyArg<undefined>

Added in v2.0.0 v2.0.0 中添加

constVoid   常量空

A thunk that returns always void.
始终返回 void 的 thunk。

Signature 签名

export declare const constVoid: LazyArg<void>

Added in v2.0.0 v2.0.0 中添加

constant   持续的

Signature 签名

export declare function constant<A>(a: A): LazyArg<A>

Added in v2.0.0 v2.0.0 中添加

decrement   递减

Signature 签名

export declare function decrement(n: number): number

Added in v2.0.0 v2.0.0 中添加

flip   翻动

Flips the arguments of a curried function.
翻转柯里化函数的参数。

Signature 签名

export declare function flip<A, B, C>(f: (a: A) => (b: B) => C): (b: B) => (a: A) => C
export declare function flip<A, B, C>(f: (a: A, b: B) => C): (b: B, a: A) => C

Example 例子

import { flip } from 'fp-ts/function'

const f = (a: number) => (b: string) => a - b.length

assert.strictEqual(flip(f)('aaa')(2), -1)

Added in v2.0.0 v2.0.0 中添加

flow   流动

Performs left-to-right function composition. The first argument may have any arity, the remaining arguments must be unary.
执行从左到右的函数组合。第一个参数可以具有任意元数,其余参数必须是一元的。

See also pipe. 另请参阅 pipe

Signature 签名

export declare function flow<A extends ReadonlyArray<unknown>, B>(ab: (...a: A) => B): (...a: A) => B
export declare function flow<A extends ReadonlyArray<unknown>, B, C>(
  ab: (...a: A) => B,
  bc: (b: B) => C
): (...a: A) => C
export declare function flow<A extends ReadonlyArray<unknown>, B, C, D>(
  ab: (...a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D
): (...a: A) => D
export declare function flow<A extends ReadonlyArray<unknown>, B, C, D, E>(
  ab: (...a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E
): (...a: A) => E
export declare function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F>(
  ab: (...a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F
): (...a: A) => F
export declare function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F, G>(
  ab: (...a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F,
  fg: (f: F) => G
): (...a: A) => G
export declare function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F, G, H>(
  ab: (...a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F,
  fg: (f: F) => G,
  gh: (g: G) => H
): (...a: A) => H
export declare function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F, G, H, I>(
  ab: (...a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F,
  fg: (f: F) => G,
  gh: (g: G) => H,
  hi: (h: H) => I
): (...a: A) => I
export declare function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F, G, H, I, J>(
  ab: (...a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F,
  fg: (f: F) => G,
  gh: (g: G) => H,
  hi: (h: H) => I,
  ij: (i: I) => J
): (...a: A) => J

Example 例子

import { flow } from 'fp-ts/function'

const len = (s: string): number => s.length
const double = (n: number): number => n * 2

const f = flow(len, double)

assert.strictEqual(f('aaa'), 6)

Added in v2.0.0 v2.0.0 中添加

hole  

Type hole simulation 型孔模拟

Signature 签名

export declare const hole: <T>() => T

Added in v2.7.0 v2.7.0 中添加

identity   身份

Signature 签名

export declare function identity<A>(a: A): A

Added in v2.0.0 v2.0.0 中添加

increment   增量

Signature 签名

export declare function increment(n: number): number

Added in v2.0.0 v2.0.0 中添加

pipe   管道

Pipes the value of an expression into a pipeline of functions.
将表达式的值通过管道传输到函数管道中。

See also flow. 另请参阅 flow

Signature 签名

export declare function pipe<A>(a: A): A
export declare function pipe<A, B>(a: A, ab: (a: A) => B): B
export declare function pipe<A, B, C>(a: A, ab: (a: A) => B, bc: (b: B) => C): C
export declare function pipe<A, B, C, D>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D): D
export declare function pipe<A, B, C, D, E>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E): E
export declare function pipe<A, B, C, D, E, F>(
  a: A,
  ab: (a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F
): F
export declare function pipe<A, B, C, D, E, F, G>(
  a: A,
  ab: (a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F,
  fg: (f: F) => G
): G
export declare function pipe<A, B, C, D, E, F, G, H>(
  a: A,
  ab: (a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F,
  fg: (f: F) => G,
  gh: (g: G) => H
): H
export declare function pipe<A, B, C, D, E, F, G, H, I>(
  a: A,
  ab: (a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F,
  fg: (f: F) => G,
  gh: (g: G) => H,
  hi: (h: H) => I
): I
export declare function pipe<A, B, C, D, E, F, G, H, I, J>(
  a: A,
  ab: (a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F,
  fg: (f: F) => G,
  gh: (g: G) => H,
  hi: (h: H) => I,
  ij: (i: I) => J
): J
export declare function pipe<A, B, C, D, E, F, G, H, I, J, K>(
  a: A,
  ab: (a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F,
  fg: (f: F) => G,
  gh: (g: G) => H,
  hi: (h: H) => I,
  ij: (i: I) => J,
  jk: (j: J) => K
): K
export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L>(
  a: A,
  ab: (a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F,
  fg: (f: F) => G,
  gh: (g: G) => H,
  hi: (h: H) => I,
  ij: (i: I) => J,
  jk: (j: J) => K,
  kl: (k: K) => L
): L
export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M>(
  a: A,
  ab: (a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F,
  fg: (f: F) => G,
  gh: (g: G) => H,
  hi: (h: H) => I,
  ij: (i: I) => J,
  jk: (j: J) => K,
  kl: (k: K) => L,
  lm: (l: L) => M
): M
export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N>(
  a: A,
  ab: (a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F,
  fg: (f: F) => G,
  gh: (g: G) => H,
  hi: (h: H) => I,
  ij: (i: I) => J,
  jk: (j: J) => K,
  kl: (k: K) => L,
  lm: (l: L) => M,
  mn: (m: M) => N
): N
export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(
  a: A,
  ab: (a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F,
  fg: (f: F) => G,
  gh: (g: G) => H,
  hi: (h: H) => I,
  ij: (i: I) => J,
  jk: (j: J) => K,
  kl: (k: K) => L,
  lm: (l: L) => M,
  mn: (m: M) => N,
  no: (n: N) => O
): O
export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>(
  a: A,
  ab: (a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F,
  fg: (f: F) => G,
  gh: (g: G) => H,
  hi: (h: H) => I,
  ij: (i: I) => J,
  jk: (j: J) => K,
  kl: (k: K) => L,
  lm: (l: L) => M,
  mn: (m: M) => N,
  no: (n: N) => O,
  op: (o: O) => P
): P
export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q>(
  a: A,
  ab: (a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F,
  fg: (f: F) => G,
  gh: (g: G) => H,
  hi: (h: H) => I,
  ij: (i: I) => J,
  jk: (j: J) => K,
  kl: (k: K) => L,
  lm: (l: L) => M,
  mn: (m: M) => N,
  no: (n: N) => O,
  op: (o: O) => P,
  pq: (p: P) => Q
): Q
export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R>(
  a: A,
  ab: (a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F,
  fg: (f: F) => G,
  gh: (g: G) => H,
  hi: (h: H) => I,
  ij: (i: I) => J,
  jk: (j: J) => K,
  kl: (k: K) => L,
  lm: (l: L) => M,
  mn: (m: M) => N,
  no: (n: N) => O,
  op: (o: O) => P,
  pq: (p: P) => Q,
  qr: (q: Q) => R
): R
export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S>(
  a: A,
  ab: (a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F,
  fg: (f: F) => G,
  gh: (g: G) => H,
  hi: (h: H) => I,
  ij: (i: I) => J,
  jk: (j: J) => K,
  kl: (k: K) => L,
  lm: (l: L) => M,
  mn: (m: M) => N,
  no: (n: N) => O,
  op: (o: O) => P,
  pq: (p: P) => Q,
  qr: (q: Q) => R,
  rs: (r: R) => S
): S
export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T>(
  a: A,
  ab: (a: A) => B,
  bc: (b: B) => C,
  cd: (c: C) => D,
  de: (d: D) => E,
  ef: (e: E) => F,
  fg: (f: F) => G,
  gh: (g: G) => H,
  hi: (h: H) => I,
  ij: (i: I) => J,
  jk: (j: J) => K,
  kl: (k: K) => L,
  lm: (l: L) => M,
  mn: (m: M) => N,
  no: (n: N) => O,
  op: (o: O) => P,
  pq: (p: P) => Q,
  qr: (q: Q) => R,
  rs: (r: R) => S,
  st: (s: S) => T
): T

Example 例子

import { pipe } from 'fp-ts/function'

const len = (s: string): number => s.length
const double = (n: number): number => n * 2

// without pipe
assert.strictEqual(double(len('aaa')), 6)

// with pipe
assert.strictEqual(pipe('aaa', len, double), 6)

Added in v2.6.3 v2.6.3 中添加

tuple   元组

Signature 签名

export declare function tuple<T extends ReadonlyArray<any>>(...t: T): T

Added in v2.0.0 v2.0.0 中添加

tupled   元组

Creates a tupled version of this function: instead of n arguments, it accepts a single tuple argument.
创建此函数的元组版本:它接受单个元组参数,而不是 n 参数。

Signature 签名

export declare function tupled<A extends ReadonlyArray<unknown>, B>(f: (...a: A) => B): (a: A) => B

Example 例子

import { tupled } from 'fp-ts/function'

const add = tupled((x: number, y: number): number => x + y)

assert.strictEqual(add([1, 2]), 3)

Added in v2.4.0 v2.4.0中添加

unsafeCoerce   不安全强制

Signature 签名

export declare const unsafeCoerce: <A, B>(a: A) => B

Added in v2.0.0 v2.0.0 中添加

untupled   未配对的

Inverse function of tupled @0的反函数#

Signature 签名

export declare function untupled<A extends ReadonlyArray<unknown>, B>(f: (a: A) => B): (...a: A) => B

Added in v2.4.0 v2.4.0中添加

zone of death
死亡地带

Endomorphism 自同态 (interface)   (界面)

Use Endomorphism module instead. 请改用 Endomorphism 模块。

Signature 签名

export interface Endomorphism<A> {
  (a: A): A
}

Added in v2.0.0 v2.0.0 中添加

Predicate 谓词 (interface)   (界面)

Use Predicate module instead. 请改用 Predicate 模块。

Signature 签名

export interface Predicate<A> {
  (a: A): boolean
}

Added in v2.0.0 v2.0.0 中添加

Refinement 细化 (interface)   (界面)

Use Refinement module instead. 请改用 Refinement 模块。

Signature 签名

export interface Refinement<A, B extends A> {
  (a: A): a is B
}

Added in v2.0.0 v2.0.0 中添加

getEndomorphismMonoid 获取内同态Monoid

Use Endomorphism module instead. 请改用 Endomorphism 模块。

Signature 签名

export declare const getEndomorphismMonoid: <A = never>() => Monoid<Endomorphism<A>>

Added in v2.10.0 v2.10.0 中添加

not 不是

Use Predicate module instead. 请改用 Predicate 模块。

Signature 签名

export declare function not<A>(predicate: Predicate<A>): Predicate<A>

Added in v2.0.0 v2.0.0 中添加

Functor overview  函子概述

A Functor is a type constructor which supports a mapping operation map.
Functor 是支持映射操作 map 的类型构造函数。

map can be used to turn functions a -> b into functions f a -> f b whose argument and return types use the type constructor f to represent some computational context.
map 可用于将函数 a -> b 转换为函数 f a -> f b ,其参数和返回类型使用类型构造函数 f 来表示某些计算上下文。

Instances must satisfy the following laws:
实例必须满足以下定律:

  1. Identity: F.map(fa, a => a) <-> fa 身份: F.map(fa, a => a) <-> fa
  2. Composition: F.map(fa, a => bc(ab(a))) <-> F.map(F.map(fa, ab), bc) 成分: F.map(fa, a => bc(ab(a))) <-> F.map(F.map(fa, ab), bc)

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


mapping   映射

flap   皮瓣

Signature 签名

export declare function flap<F extends URIS4>(
  F: Functor4<F>
): <A>(a: A) => <S, R, E, B>(fab: Kind4<F, S, R, E, (a: A) => B>) => Kind4<F, S, R, E, B>
export declare function flap<F extends URIS3>(
  F: Functor3<F>
): <A>(a: A) => <R, E, B>(fab: Kind3<F, R, E, (a: A) => B>) => Kind3<F, R, E, B>
export declare function flap<F extends URIS2>(
  F: Functor2<F>
): <A>(a: A) => <E, B>(fab: Kind2<F, E, (a: A) => B>) => Kind2<F, E, B>
export declare function flap<F extends URIS>(F: Functor1<F>): <A>(a: A) => <B>(fab: Kind<F, (a: A) => B>) => Kind<F, B>
export declare function flap<F>(F: Functor<F>): <A>(a: A) => <B>(fab: HKT<F, (a: A) => B>) => HKT<F, B>

Added in v2.10.0 v2.10.0 中添加

model   模型

Functor (interface)   函子(接口)

Signature 签名

export interface Functor<F> {
  readonly URI: F
  readonly map: <A, B>(fa: HKT<F, A>, f: (a: A) => B) => HKT<F, B>
}

Added in v2.0.0 v2.0.0 中添加

Functor1 (interface)   函子1(接口)

Signature 签名

export interface Functor1<F extends URIS> {
  readonly URI: F
  readonly map: <A, B>(fa: Kind<F, A>, f: (a: A) => B) => Kind<F, B>
}

Added in v2.0.0 v2.0.0 中添加

Functor2 (interface)   函子2(接口)

Signature 签名

export interface Functor2<F extends URIS2> {
  readonly URI: F
  readonly map: <E, A, B>(fa: Kind2<F, E, A>, f: (a: A) => B) => Kind2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

Functor2C (interface)   Functor2C(接口)

Signature 签名

export interface Functor2C<F extends URIS2, E> {
  readonly URI: F
  readonly _E: E
  readonly map: <A, B>(fa: Kind2<F, E, A>, f: (a: A) => B) => Kind2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

Functor3 (interface)   Functor3(接口)

Signature 签名

export interface Functor3<F extends URIS3> {
  readonly URI: F
  readonly map: <R, E, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => B) => Kind3<F, R, E, B>
}

Added in v2.0.0 v2.0.0 中添加

Functor3C (interface)   Functor3C(接口)

Signature 签名

export interface Functor3C<F extends URIS3, E> {
  readonly URI: F
  readonly _E: E
  readonly map: <R, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => B) => Kind3<F, R, E, B>
}

Added in v2.2.0 v2.2.0中添加

Functor4 (interface)   Functor4(接口)

Signature 签名

export interface Functor4<F extends URIS4> {
  readonly URI: F
  readonly map: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, f: (a: A) => B) => Kind4<F, S, R, E, B>
}

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

bindTo   绑定到

Signature 签名

export declare function bindTo<F extends URIS4>(
  F: Functor4<F>
): <N extends string>(name: N) => <S, R, E, A>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, { readonly [K in N]: A }>
export declare function bindTo<F extends URIS3>(
  F: Functor3<F>
): <N extends string>(name: N) => <R, E, A>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, { readonly [K in N]: A }>
export declare function bindTo<F extends URIS3, E>(
  F: Functor3C<F, E>
): <N extends string>(name: N) => <R, A>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, { readonly [K in N]: A }>
export declare function bindTo<F extends URIS2>(
  F: Functor2<F>
): <N extends string>(name: N) => <E, A>(fa: Kind2<F, E, A>) => Kind2<F, E, { readonly [K in N]: A }>
export declare function bindTo<F extends URIS2, E>(
  F: Functor2C<F, E>
): <N extends string>(name: N) => <A>(fa: Kind2<F, E, A>) => Kind2<F, E, { readonly [K in N]: A }>
export declare function bindTo<F extends URIS>(
  F: Functor1<F>
): <N extends string>(name: N) => <A>(fa: Kind<F, A>) => Kind<F, { readonly [K in N]: A }>
export declare function bindTo<F>(
  F: Functor<F>
): <N extends string>(name: N) => <A>(fa: HKT<F, A>) => HKT<F, { readonly [K in N]: A }>

Added in v2.10.0 v2.10.0 中添加

let  

Signature 签名

export declare const let: typeof let_

Added in v2.13.0 v2.13.0 中添加

let_   让_

Signature 签名

function let_<F extends URIS4>(
  F: Functor4<F>
): <N extends string, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => <S, R, E>(
  fa: Kind4<F, S, R, E, A>
) => Kind4<F, S, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>
function let_<F extends URIS3>(
  F: Functor3<F>
): <N extends string, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>
function let_<F extends URIS3, E>(
  F: Functor3C<F, E>
): <N extends string, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>
function let_<F extends URIS2>(
  F: Functor2<F>
): <N extends string, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>
function let_<F extends URIS2, E>(
  F: Functor2C<F, E>
): <N extends string, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => (fa: Kind2<F, E, A>) => Kind2<F, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>
function let_<F extends URIS>(
  F: Functor1<F>
): <N extends string, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => (fa: Kind<F, A>) => Kind<F, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>
function let_<F>(
  F: Functor<F>
): <N extends string, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => (fa: HKT<F, A>) => HKT<F, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>

Added in v2.13.0 v2.13.0 中添加

map   地图

map composition.

Signature 签名

export declare function map<F extends URIS3, G extends URIS>(
  F: Functor3<F>,
  G: Functor1<G>
): <A, B>(f: (a: A) => B) => <R, E>(fa: Kind3<F, R, E, Kind<G, A>>) => Kind3<F, R, E, Kind<G, B>>
export declare function map<F extends URIS2, G extends URIS2>(
  F: Functor2<F>,
  G: Functor2<G>
): <A, B>(f: (a: A) => B) => <EF, EG>(fa: Kind2<F, EF, Kind2<G, EG, A>>) => Kind2<F, EF, Kind2<G, EG, B>>
export declare function map<F extends URIS2, G extends URIS>(
  F: Functor2<F>,
  G: Functor1<G>
): <A, B>(f: (a: A) => B) => <E>(fa: Kind2<F, E, Kind<G, A>>) => Kind2<F, E, Kind<G, B>>
export declare function map<F extends URIS, G extends URIS3>(
  F: Functor1<F>,
  G: Functor3<G>
): <A, B>(f: (a: A) => B) => <R, E>(fa: Kind<F, Kind3<G, R, E, A>>) => Kind<F, Kind3<G, R, E, B>>
export declare function map<F extends URIS, G extends URIS2>(
  F: Functor1<F>,
  G: Functor2<G>
): <A, B>(f: (a: A) => B) => <E>(fa: Kind<F, Kind2<G, E, A>>) => Kind<F, Kind2<G, E, B>>
export declare function map<F extends URIS, G extends URIS>(
  F: Functor1<F>,
  G: Functor1<G>
): <A, B>(f: (a: A) => B) => (fa: Kind<F, Kind<G, A>>) => Kind<F, Kind<G, B>>
export declare function map<F, G extends URIS2>(
  F: Functor<F>,
  G: Functor2<G>
): <A, B>(f: (a: A) => B) => <E>(fa: HKT<F, Kind2<G, E, A>>) => HKT<F, Kind2<G, E, B>>
export declare function map<F, G extends URIS>(
  F: Functor<F>,
  G: Functor1<G>
): <A, B>(f: (a: A) => B) => (fa: HKT<F, Kind<G, A>>) => HKT<F, Kind<G, B>>
export declare function map<F, G>(
  F: Functor<F>,
  G: Functor<G>
): <A, B>(f: (a: A) => B) => (fa: HKT<F, HKT<G, A>>) => HKT<F, HKT<G, B>>

Added in v2.10.0 v2.10.0 中添加

zone of death
死亡地带

FunctorComposition11 函子Composition11 (interface)   (界面)

Signature 签名

export interface FunctorComposition11<F extends URIS, G extends URIS> {
  readonly map: <A, B>(fa: Kind<F, Kind<G, A>>, f: (a: A) => B) => Kind<F, Kind<G, B>>
}

Added in v2.0.0 v2.0.0 中添加

FunctorComposition12C FunctorComposition12C (interface)   (界面)

Signature 签名

export interface FunctorComposition12C<F extends URIS, G extends URIS2, E> {
  readonly map: <A, B>(fa: Kind<F, Kind2<G, E, A>>, f: (a: A) => B) => Kind<F, Kind2<G, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

FunctorComposition12 函子Composition12 (interface)   (界面)

Signature 签名

export interface FunctorComposition12<F extends URIS, G extends URIS2> {
  readonly map: <E, A, B>(fa: Kind<F, Kind2<G, E, A>>, f: (a: A) => B) => Kind<F, Kind2<G, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

FunctorComposition21 函子Composition21 (interface)   (界面)

Signature 签名

export interface FunctorComposition21<F extends URIS2, G extends URIS> {
  readonly map: <E, A, B>(fa: Kind2<F, E, Kind<G, A>>, f: (a: A) => B) => Kind2<F, E, Kind<G, B>>
}

Added in v2.0.0 v2.0.0 中添加

FunctorComposition22C FunctorComposition22C (interface)   (界面)

Signature 签名

export interface FunctorComposition22C<F extends URIS2, G extends URIS2, E> {
  readonly map: <FE, A, B>(fa: Kind2<F, FE, Kind2<G, E, A>>, f: (a: A) => B) => Kind2<F, FE, Kind2<G, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

FunctorComposition22 函子Composition22 (interface)   (界面)

Signature 签名

export interface FunctorComposition22<F extends URIS2, G extends URIS2> {
  readonly map: <FE, GE, A, B>(fa: Kind2<F, FE, Kind2<G, GE, A>>, f: (a: A) => B) => Kind2<F, FE, Kind2<G, GE, B>>
}

Added in v2.0.0 v2.0.0 中添加

FunctorComposition23C FunctorComposition23C (interface)   (界面)

Signature 签名

export interface FunctorComposition23C<F extends URIS2, G extends URIS3, E> {
  readonly map: <FE, R, A, B>(fa: Kind2<F, FE, Kind3<G, R, E, A>>, f: (a: A) => B) => Kind2<F, FE, Kind3<G, R, E, B>>
}

Added in v2.2.0 v2.2.0中添加

FunctorComposition23 函子Composition23 (interface)   (界面)

Signature 签名

export interface FunctorComposition23<F extends URIS2, G extends URIS3> {
  readonly map: <FE, R, E, A, B>(fa: Kind2<F, FE, Kind3<G, R, E, A>>, f: (a: A) => B) => Kind2<F, FE, Kind3<G, R, E, B>>
}

Added in v2.2.0 v2.2.0中添加

FunctorComposition2C1 函子Composition2C1 (interface)   (界面)

Signature 签名

export interface FunctorComposition2C1<F extends URIS2, G extends URIS, E> {
  readonly map: <A, B>(fa: Kind2<F, E, Kind<G, A>>, f: (a: A) => B) => Kind2<F, E, Kind<G, B>>
}

Added in v2.0.0 v2.0.0 中添加

FunctorCompositionHKT1 函子组合HKT1 (interface)   (界面)

Signature 签名

export interface FunctorCompositionHKT1<F, G extends URIS> {
  readonly map: <A, B>(fa: HKT<F, Kind<G, A>>, f: (a: A) => B) => HKT<F, Kind<G, B>>
}

Added in v2.0.0 v2.0.0 中添加

FunctorCompositionHKT2C FunctorCompositionHKT2C (interface)   (界面)

Signature 签名

export interface FunctorCompositionHKT2C<F, G extends URIS2, E> {
  readonly map: <A, B>(fa: HKT<F, Kind2<G, E, A>>, f: (a: A) => B) => HKT<F, Kind2<G, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

FunctorCompositionHKT2 FunctorCompositionHKT2 (interface)   (界面)

Signature 签名

export interface FunctorCompositionHKT2<F, G extends URIS2> {
  readonly map: <E, A, B>(fa: HKT<F, Kind2<G, E, A>>, f: (a: A) => B) => HKT<F, Kind2<G, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

FunctorComposition 函子组合 (interface)   (界面)

Signature 签名

export interface FunctorComposition<F, G> {
  readonly map: <A, B>(fa: HKT<F, HKT<G, A>>, f: (a: A) => B) => HKT<F, HKT<G, B>>
}

Added in v2.0.0 v2.0.0 中添加

getFunctorComposition 获取函子组合

Use map instead. 请改用 map

Signature 签名

export declare function getFunctorComposition<F extends URIS2, G extends URIS3, E>(
  F: Functor2<F>,
  G: Functor3C<G, E>
): FunctorComposition23C<F, G, E>
export declare function getFunctorComposition<F extends URIS2, G extends URIS2, E>(
  F: Functor2<F>,
  G: Functor2C<G, E>
): FunctorComposition22C<F, G, E>
export declare function getFunctorComposition<F extends URIS2, G extends URIS2>(
  F: Functor2<F>,
  G: Functor2<G>
): FunctorComposition22<F, G>
export declare function getFunctorComposition<F extends URIS2, G extends URIS, E>(
  F: Functor2C<F, E>,
  G: Functor1<G>
): FunctorComposition2C1<F, G, E>
export declare function getFunctorComposition<F extends URIS2, G extends URIS>(
  F: Functor2<F>,
  G: Functor1<G>
): FunctorComposition21<F, G>
export declare function getFunctorComposition<F extends URIS, G extends URIS2, E>(
  F: Functor1<F>,
  G: Functor2C<G, E>
): FunctorComposition12C<F, G, E>
export declare function getFunctorComposition<F extends URIS, G extends URIS2>(
  F: Functor1<F>,
  G: Functor2<G>
): FunctorComposition12<F, G>
export declare function getFunctorComposition<F extends URIS, G extends URIS>(
  F: Functor1<F>,
  G: Functor1<G>
): FunctorComposition11<F, G>
export declare function getFunctorComposition<F, G>(F: Functor<F>, G: Functor<G>): FunctorComposition<F, G>

Added in v2.0.0 v2.0.0 中添加

FunctorWithIndex overview
FunctorWithIndex 概述

A FunctorWithIndex is a type constructor which supports a mapping operation mapWithIndex.
FunctorWithIndex 是支持映射操作 mapWithIndex 的类型构造函数。

mapWithIndex can be used to turn functions i -> a -> b into functions f a -> f b whose argument and return types use the type constructor f to represent some computational context.
mapWithIndex 可用于将函数 i -> a -> b 转换为函数 f a -> f b ,其参数和返回类型使用类型构造函数 f 来表示某些计算上下文。

Instances must satisfy the following laws:
实例必须满足以下定律:

  1. Identity: F.mapWithIndex(fa, (_i, a) => a) <-> fa 身份: F.mapWithIndex(fa, (_i, a) => a) <-> fa
  2. Composition: F.mapWithIndex(fa, (_i, a) => bc(ab(a))) <-> F.mapWithIndex(F.mapWithIndex(fa, ab), bc) 成分: F.mapWithIndex(fa, (_i, a) => bc(ab(a))) <-> F.mapWithIndex(F.mapWithIndex(fa, ab), bc)

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

FunctorWithIndex (interface)
带索引的函子(接口)

Signature 签名

export interface FunctorWithIndex<F, I> extends Functor<F> {
  readonly mapWithIndex: <A, B>(fa: HKT<F, A>, f: (i: I, a: A) => B) => HKT<F, B>
}

Added in v2.0.0 v2.0.0 中添加

FunctorWithIndex1 (interface)
FunctorWithIndex1(接口)

Signature 签名

export interface FunctorWithIndex1<F extends URIS, I> extends Functor1<F> {
  readonly mapWithIndex: <A, B>(fa: Kind<F, A>, f: (i: I, a: A) => B) => Kind<F, B>
}

Added in v2.0.0 v2.0.0 中添加

FunctorWithIndex2 (interface)
FunctorWithIndex2(接口)

Signature 签名

export interface FunctorWithIndex2<F extends URIS2, I> extends Functor2<F> {
  readonly mapWithIndex: <E, A, B>(fa: Kind2<F, E, A>, f: (i: I, a: A) => B) => Kind2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

FunctorWithIndex2C (interface)
FunctorWithIndex2C(接口)

Signature 签名

export interface FunctorWithIndex2C<F extends URIS2, I, E> extends Functor2C<F, E> {
  readonly mapWithIndex: <A, B>(fa: Kind2<F, E, A>, f: (i: I, a: A) => B) => Kind2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

FunctorWithIndex3 (interface)
FunctorWithIndex3(接口)

Signature 签名

export interface FunctorWithIndex3<F extends URIS3, I> extends Functor3<F> {
  readonly mapWithIndex: <R, E, A, B>(fa: Kind3<F, R, E, A>, f: (i: I, a: A) => B) => Kind3<F, R, E, B>
}

Added in v2.0.0 v2.0.0 中添加

FunctorWithIndex3C (interface)
FunctorWithIndex3C(接口)

Signature 签名

export interface FunctorWithIndex3C<F extends URIS3, I, E> extends Functor3C<F, E> {
  readonly mapWithIndex: <R, A, B>(fa: Kind3<F, R, E, A>, f: (i: I, a: A) => B) => Kind3<F, R, E, B>
}

Added in v2.2.0 v2.2.0中添加

FunctorWithIndex4 (interface)
FunctorWithIndex4(接口)

Signature 签名

export interface FunctorWithIndex4<F extends URIS4, I> extends Functor4<F> {
  readonly mapWithIndex: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, f: (i: I, a: A) => B) => Kind4<F, S, R, E, B>
}

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

mapWithIndex   带索引的映射

mapWithIndex composition.

Signature 签名

export declare function mapWithIndex<F extends URIS, I, G extends URIS, J>(
  F: FunctorWithIndex1<F, I>,
  G: FunctorWithIndex1<G, J>
): <A, B>(f: (ij: readonly [I, J], a: A) => B) => (fa: Kind<F, Kind<G, A>>) => Kind<F, Kind<G, B>>
export declare function mapWithIndex<F, I, G, J>(
  F: FunctorWithIndex<F, I>,
  G: FunctorWithIndex<G, J>
): <A, B>(f: (ij: readonly [I, J], a: A) => B) => (fa: HKT<F, HKT<G, A>>) => HKT<F, HKT<G, B>>

Added in v2.10.0 v2.10.0 中添加

zone of death
死亡地带

FunctorWithIndexComposition11
FunctorWithIndexComposition11
(interface)   (界面)

Signature 签名

export interface FunctorWithIndexComposition11<F extends URIS, FI, G extends URIS, GI>
  extends FunctorComposition11<F, G> {
  readonly mapWithIndex: <A, B>(fa: Kind<F, Kind<G, A>>, f: (i: [FI, GI], a: A) => B) => Kind<F, Kind<G, B>>
}

Added in v2.0.0 v2.0.0 中添加

FunctorWithIndexComposition12C
FunctorWithIndexComposition12C
(interface)   (界面)

Signature 签名

export interface FunctorWithIndexComposition12C<F extends URIS, FI, G extends URIS2, GI, E>
  extends FunctorComposition12C<F, G, E> {
  readonly mapWithIndex: <A, B>(fa: Kind<F, Kind2<G, E, A>>, f: (i: [FI, GI], a: A) => B) => Kind<F, Kind2<G, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

FunctorWithIndexComposition12
FunctorWithIndexComposition12
(interface)   (界面)

Signature 签名

export interface FunctorWithIndexComposition12<F extends URIS, FI, G extends URIS2, GI>
  extends FunctorComposition12<F, G> {
  readonly mapWithIndex: <E, A, B>(fa: Kind<F, Kind2<G, E, A>>, f: (i: [FI, GI], a: A) => B) => Kind<F, Kind2<G, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

FunctorWithIndexComposition21
FunctorWithIndexComposition21
(interface)   (界面)

Signature 签名

export interface FunctorWithIndexComposition21<F extends URIS2, FI, G extends URIS, GI>
  extends FunctorComposition21<F, G> {
  readonly mapWithIndex: <E, A, B>(fa: Kind2<F, E, Kind<G, A>>, f: (i: [FI, GI], a: A) => B) => Kind2<F, E, Kind<G, B>>
}

Added in v2.0.0 v2.0.0 中添加

FunctorWithIndexComposition22C
FunctorWithIndexComposition22C
(interface)   (界面)

Signature 签名

export interface FunctorWithIndexComposition22C<F extends URIS2, FI, G extends URIS2, GI, E>
  extends FunctorComposition22C<F, G, E> {
  readonly mapWithIndex: <FE, A, B>(
    fa: Kind2<F, FE, Kind2<G, E, A>>,
    f: (i: [FI, GI], a: A) => B
  ) => Kind2<F, FE, Kind2<G, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

FunctorWithIndexComposition22
FunctorWithIndexComposition22
(interface)   (界面)

Signature 签名

export interface FunctorWithIndexComposition22<F extends URIS2, FI, G extends URIS2, GI>
  extends FunctorComposition22<F, G> {
  readonly mapWithIndex: <FE, GE, A, B>(
    fa: Kind2<F, FE, Kind2<G, GE, A>>,
    f: (i: [FI, GI], a: A) => B
  ) => Kind2<F, FE, Kind2<G, GE, B>>
}

Added in v2.0.0 v2.0.0 中添加

FunctorWithIndexComposition2C1
FunctorWithIndexComposition2C1
(interface)   (界面)

Signature 签名

export interface FunctorWithIndexComposition2C1<F extends URIS2, FI, G extends URIS, GI, E>
  extends FunctorComposition2C1<F, G, E> {
  readonly mapWithIndex: <A, B>(fa: Kind2<F, E, Kind<G, A>>, f: (i: [FI, GI], a: A) => B) => Kind2<F, E, Kind<G, B>>
}

Added in v2.0.0 v2.0.0 中添加

FunctorWithIndexComposition
带索引组合的函子
(interface)   (界面)

Signature 签名

export interface FunctorWithIndexComposition<F, FI, G, GI> extends FunctorComposition<F, G> {
  readonly mapWithIndex: <A, B>(fga: HKT<F, HKT<G, A>>, f: (i: [FI, GI], a: A) => B) => HKT<F, HKT<G, B>>
}

Added in v2.0.0 v2.0.0 中添加

getFunctorWithIndexComposition
getFunctorWithIndexComposition

Use mapWithIndex instead. 请改用 mapWithIndex

Signature 签名

export declare function getFunctorWithIndexComposition<F extends URIS2, FI, G extends URIS2, GI, E>(
  F: FunctorWithIndex2<F, FI>,
  G: FunctorWithIndex2C<G, FI, E>
): FunctorWithIndexComposition22C<F, FI, G, GI, E>
export declare function getFunctorWithIndexComposition<F extends URIS2, FI, G extends URIS2, GI>(
  F: FunctorWithIndex2<F, FI>,
  G: FunctorWithIndex2<G, FI>
): FunctorWithIndexComposition22<F, FI, G, GI>
export declare function getFunctorWithIndexComposition<F extends URIS2, FI, G extends URIS, GI, E>(
  F: FunctorWithIndex2C<F, FI, E>,
  G: FunctorWithIndex1<G, GI>
): FunctorWithIndexComposition2C1<F, FI, G, GI, E>
export declare function getFunctorWithIndexComposition<F extends URIS2, FI, G extends URIS, GI>(
  F: FunctorWithIndex2<F, FI>,
  G: FunctorWithIndex1<G, GI>
): FunctorWithIndexComposition21<F, FI, G, GI>
export declare function getFunctorWithIndexComposition<F extends URIS, FI, G extends URIS2, GI, E>(
  F: FunctorWithIndex1<F, FI>,
  G: FunctorWithIndex2C<G, GI, E>
): FunctorWithIndexComposition12C<F, FI, G, GI, E>
export declare function getFunctorWithIndexComposition<F extends URIS, FI, G extends URIS2, GI>(
  F: FunctorWithIndex1<F, FI>,
  G: FunctorWithIndex2<G, GI>
): FunctorWithIndexComposition12<F, FI, G, GI>
export declare function getFunctorWithIndexComposition<F extends URIS, FI, G extends URIS, GI>(
  F: FunctorWithIndex1<F, FI>,
  G: FunctorWithIndex1<G, GI>
): FunctorWithIndexComposition11<F, FI, G, GI>
export declare function getFunctorWithIndexComposition<F, FI, G, GI>(
  F: FunctorWithIndex<F, FI>,
  G: FunctorWithIndex<G, GI>
): FunctorWithIndexComposition<F, FI, G, GI>

Added in v2.0.0 v2.0.0 中添加

Group overview  集团概况

A Group is a Monoid with inverses. Instances must satisfy the following law in addition to the monoid laws:
Group 是带有逆元的 Monoid 。除了幺半群法则之外,实例还必须满足以下法则:

  • Inverse: concat(inverse(a), a) <-> empty = concat(a, inverse(a)) 逆: concat(inverse(a), a) <-> empty = concat(a, inverse(a))

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Group (interface)   组(界面)

Signature 签名

export interface Group<A> extends Monoid<A> {
  readonly inverse: (a: A) => A
}

Added in v2.0.0 v2.0.0 中添加

HeytingAlgebra overview
海廷代数概述

Heyting algebras are bounded (distributive) lattices that are also equipped with an additional binary operation implies (also written as ). Heyting algebras also define a complement operation not (sometimes written as ¬a)
Heyting 代数是有界(分配)格,还配备了额外的二元运算 implies (也写为 )。 Heyting 代数还定义补运算 not (有时写为 ¬a

However, in Heyting algebras this operation is only a pseudo-complement, since Heyting algebras do not necessarily provide the law of the excluded middle. This means that there is no guarantee that a ∨ ¬a = 1.
然而,在 Heyting 代数中,这种运算只是伪补,因为 Heyting 代数不一定提供排中律。这意味着不能保证 a ∨ ¬a = 1

Heyting algebras model intuitionistic logic. For a model of classical logic, see the boolean algebra type class implemented as BooleanAlgebra.
海廷代数模型直观逻辑。对于经典逻辑模型,请参阅实现为 BooleanAlgebra 的布尔代数类型类。

A HeytingAlgebra must satisfy the following laws in addition to BoundedDistributiveLattice laws:
除了 BoundedDistributiveLattice 法则之外, HeytingAlgebra 还必须满足以下法则:

  • Implication:  含义:
    • a → a <-> 1
    • a ∧ (a → b) <-> a ∧ b
    • b ∧ (a → b) <-> b
    • a → (b ∧ c) <-> (a → b) ∧ (a → c)
  • Complemented  补充
    • ¬a <-> a → 0

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

HeytingAlgebra (interface)
海廷代数(接口)

Signature 签名

export interface HeytingAlgebra<A> extends BoundedDistributiveLattice<A> {
  readonly implies: (x: A, y: A) => A
  readonly not: (x: A) => A
}

Added in v2.0.0 v2.0.0 中添加

HKT overview  香港电讯概览

Type defunctionalization (as describe in Lightweight higher-kinded polymorphism)
类型去功能化(如轻量级高级多态性中所述)

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


utils   实用程序

HKT (interface)   HKT(接口)

* -> * constructors  * -> * 构造函数

Signature 签名

export interface HKT<URI, A> {
  readonly _URI: URI
  readonly _A: A
}

Added in v2.0.0 v2.0.0 中添加

HKT2 (interface)  HKT2(接口)

* -> * -> * constructors  * -> * -> * 构造函数

Signature 签名

export interface HKT2<URI, E, A> extends HKT<URI, A> {
  readonly _E: E
}

Added in v2.0.0 v2.0.0 中添加

HKT3 (interface)  HKT3(接口)

* -> * -> * -> * constructors  * -> * -> * -> * 构造函数

Signature 签名

export interface HKT3<URI, R, E, A> extends HKT2<URI, E, A> {
  readonly _R: R
}

Added in v2.0.0 v2.0.0 中添加

HKT4 (interface)  HKT4(接口)

* -> * -> * -> * -> * constructors  * -> * -> * -> * -> * 构造函数

Signature 签名

export interface HKT4<URI, S, R, E, A> extends HKT3<URI, R, E, A> {
  readonly _S: S
}

Added in v2.0.0 v2.0.0 中添加

Kind (type alias)
种类(类型别名)

* -> * constructors  * -> * 构造函数

Signature 签名

export type Kind<URI extends URIS, A> = URI extends URIS ? URItoKind<A>[URI] : any

Added in v2.0.0 v2.0.0 中添加

Kind2 (type alias)
Kind2(类型别名)

* -> * -> * constructors  * -> * -> * 构造函数

Signature 签名

export type Kind2<URI extends URIS2, E, A> = URI extends URIS2 ? URItoKind2<E, A>[URI] : any

Added in v2.0.0 v2.0.0 中添加

Kind3 (type alias)
Kind3(类型别名)

* -> * -> * -> * constructors  * -> * -> * -> * 构造函数

Signature 签名

export type Kind3<URI extends URIS3, R, E, A> = URI extends URIS3 ? URItoKind3<R, E, A>[URI] : any

Added in v2.0.0 v2.0.0 中添加

Kind4 (type alias)
Kind4(类型别名)

* -> * -> * -> * -> * constructors  * -> * -> * -> * -> * 构造函数

Signature 签名

export type Kind4<URI extends URIS4, S, R, E, A> = URI extends URIS4 ? URItoKind4<S, R, E, A>[URI] : any

Added in v2.0.0 v2.0.0 中添加

URIS (type alias)
URIS(类型别名)

* -> * constructors  * -> * 构造函数

Signature 签名

export type URIS = keyof URItoKind<any>

Added in v2.0.0 v2.0.0 中添加

URIS2 (type alias)
URIS2(类型别名)

* -> * -> * constructors  * -> * -> * 构造函数

Signature 签名

export type URIS2 = keyof URItoKind2<any, any>

Added in v2.0.0 v2.0.0 中添加

URIS3 (type alias)
URIS3(类型别名)

* -> * -> * -> * constructors  * -> * -> * -> * 构造函数

Signature 签名

export type URIS3 = keyof URItoKind3<any, any, any>

Added in v2.0.0 v2.0.0 中添加

URIS4 (type alias)
URIS4(类型别名)

* -> * -> * -> * -> * constructors  * -> * -> * -> * -> * 构造函数

Signature 签名

export type URIS4 = keyof URItoKind4<any, any, any, any>

Added in v2.0.0 v2.0.0 中添加

URItoKind (interface)  URItoKind(接口)

* -> * constructors  * -> * 构造函数

Signature 签名

export interface URItoKind<A> {}

Added in v2.0.0 v2.0.0 中添加

URItoKind2 (interface)  URItoKind2(接口)

* -> * -> * constructors  * -> * -> * 构造函数

Signature 签名

export interface URItoKind2<E, A> {}

Added in v2.0.0 v2.0.0 中添加

URItoKind3 (interface)  URItoKind3(接口)

* -> * -> * -> * constructors  * -> * -> * -> * 构造函数

Signature 签名

export interface URItoKind3<R, E, A> {}

Added in v2.0.0 v2.0.0 中添加

URItoKind4 (interface)  URItoKind4(接口)

* -> * -> * -> * -> * constructors  * -> * -> * -> * -> * 构造函数

Signature 签名

export interface URItoKind4<S, R, E, A> {}

Added in v2.0.0 v2.0.0 中添加

Identity overview  身份概述

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


Extract   提炼

extract   提炼

Signature 签名

export declare const extract: <A>(wa: A) => A

Added in v2.6.2 v2.6.2 中添加

constructors  构造函数

of  

Signature 签名

export declare const of: <A>(a: A) => A

Added in v2.0.0 v2.0.0 中添加

do notation   做记号

Do  

Signature 签名

export declare const Do: {}

Added in v2.9.0 v2.9.0中添加

apS   apS

Signature 签名

export declare const apS: <N, A, B>(
  name: Exclude<N, keyof A>,
  fb: B
) => (fa: A) => { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }

Added in v2.8.0 v2.8.0 中添加

bind   绑定

Signature 签名

export declare const bind: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => (ma: A) => { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }

Added in v2.8.0 v2.8.0 中添加

bindTo   绑定到

Signature 签名

export declare const bindTo: <N>(name: N) => <A>(fa: A) => { readonly [K in N]: A }

Added in v2.8.0 v2.8.0 中添加

let  

Signature 签名

export declare const let: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => (fa: A) => { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }

Added in v2.13.0 v2.13.0 中添加

error handling   错误处理

alt   替代

Identifies an associative operation on a type constructor. It is similar to Semigroup, except that it applies to types of kind * -> *.
标识类型构造函数上的关联操作。它与 Semigroup 类似,但它适用于 * -> * 类型。

Signature 签名

export declare const alt: <A>(that: () => A) => (fa: A) => A

Added in v2.0.0 v2.0.0 中添加

altW   替代W

Less strict version of alt.
alt 的不太严格版本。

The W suffix (short for Widening) means that the return types will be merged.
W 后缀(Widening 的缩写)意味着返回类型将被合并。

Signature 签名

export declare const altW: <B>(that: () => B) => <A>(fa: A) => B | A

Added in v2.9.0 v2.9.0中添加

folding   折叠式的

foldMap   折叠图

Signature 签名

export declare const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: A) => M

Added in v2.0.0 v2.0.0 中添加

reduce   减少

Signature 签名

export declare const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: A) => B

Added in v2.0.0 v2.0.0 中添加

reduceRight   减少右

Signature 签名

export declare const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: A) => B

Added in v2.0.0 v2.0.0 中添加

instances   实例

Alt   替代

Signature 签名

export declare const Alt: Alt1<'Identity'>

Added in v2.7.0 v2.7.0 中添加

Applicative   适用性

Signature 签名

export declare const Applicative: Applicative1<'Identity'>

Added in v2.7.0 v2.7.0 中添加

Apply   申请

Signature 签名

export declare const Apply: Apply1<'Identity'>

Added in v2.10.0 v2.10.0 中添加

Chain  

Signature 签名

export declare const Chain: Chain1<'Identity'>

Added in v2.10.0 v2.10.0 中添加

ChainRec   链录

Signature 签名

export declare const ChainRec: ChainRec1<'Identity'>

Added in v2.7.0 v2.7.0 中添加

Comonad   科莫纳德

Signature 签名

export declare const Comonad: Comonad1<'Identity'>

Added in v2.7.0 v2.7.0 中添加

Foldable   折叠式

Signature 签名

export declare const Foldable: Foldable1<'Identity'>

Added in v2.7.0 v2.7.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor1<'Identity'>

Added in v2.7.0 v2.7.0 中添加

Monad   单子

Signature 签名

export declare const Monad: Monad1<'Identity'>

Added in v2.7.0 v2.7.0 中添加

Pointed  

Signature 签名

export declare const Pointed: Pointed1<'Identity'>

Added in v2.10.0 v2.10.0 中添加

Traversable   可穿越

Signature 签名

export declare const Traversable: Traversable1<'Identity'>

Added in v2.7.0 v2.7.0 中添加

getEq   得到方程

Signature 签名

export declare const getEq: <A>(E: Eq<A>) => Eq<A>

Added in v2.0.0 v2.0.0 中添加

getShow   获取显示

Signature 签名

export declare const getShow: <A>(S: Show<A>) => Show<A>

Added in v2.0.0 v2.0.0 中添加

legacy   遗产

chain  

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chain: <A, B>(f: (a: A) => B) => (ma: A) => B

Added in v2.0.0 v2.0.0 中添加

mapping   映射

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <B>(fab: (a: A) => B) => B

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => (fa: A) => B

Added in v2.0.0 v2.0.0 中添加

model   模型

Identity (type alias)
身份(类型别名)

Signature 签名

export type Identity<A> = A

Added in v2.0.0 v2.0.0 中添加

sequencing   测序

chainFirst   链优先

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const chainFirst: <A, B>(f: (a: A) => B) => (first: A) => A

Added in v2.0.0 v2.0.0 中添加

flatMap   平面地图

Signature 签名

export declare const flatMap: { <A, B>(f: (a: A) => B): (ma: A) => B; <A, B>(ma: A, f: (a: A) => B): B }

Added in v2.14.0 v2.14.0 中添加

flatten   压扁

Signature 签名

export declare const flatten: <A>(mma: A) => A

Added in v2.0.0 v2.0.0 中添加

traversing   穿越

sequence   顺序

Signature 签名

export declare const sequence: Sequence1<'Identity'>

Added in v2.6.3 v2.6.3 中添加

traverse   遍历

Signature 签名

export declare const traverse: PipeableTraverse1<'Identity'>

Added in v2.6.3 v2.6.3 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'Identity'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

ap   美联社

Signature 签名

export declare const ap: <A>(fa: A) => <B>(fab: (a: A) => B) => B

Added in v2.0.0 v2.0.0 中添加

apFirst   应用程序第一

Combine two effectful actions, keeping only the result of the first.
结合两个有效的操作,仅保留第一个操作的结果。

Signature 签名

export declare const apFirst: <B>(second: B) => <A>(first: A) => A

Added in v2.0.0 v2.0.0 中添加

apSecond   ap秒

Combine two effectful actions, keeping only the result of the second.
结合两个有效的操作,只保留第二个的结果。

Signature 签名

export declare const apSecond: <B>(second: B) => <A>(first: A) => B

Added in v2.0.0 v2.0.0 中添加

duplicate   复制

Signature 签名

export declare const duplicate: <A>(ma: A) => A

Added in v2.0.0 v2.0.0 中添加

extend   延长

Signature 签名

export declare const extend: <A, B>(f: (wa: A) => B) => (wa: A) => B

Added in v2.0.0 v2.0.0 中添加

zone of death
死亡地带

identity 身份

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass I.Functor instead of I.identity (where I is from import I from 'fp-ts/Identity')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 I.Functor 而不是 I.identity (其中 I 来自 import I from 'fp-ts/Identity'

Signature 签名

export declare const identity: Monad1<'Identity'> &
  Foldable1<'Identity'> &
  Traversable1<'Identity'> &
  Alt1<'Identity'> &
  Comonad1<'Identity'> &
  ChainRec1<'Identity'>

Added in v2.0.0 v2.0.0 中添加

index overview  指数概览

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


data types   数据类型

array   大批

Signature 签名

export declare const array: typeof array

Added in v2.0.0 v2.0.0 中添加

const   常量

Signature 签名

export declare const const: typeof const_

Added in v2.0.0 v2.0.0 中添加

either   任何一个

Signature 签名

export declare const either: typeof either

Added in v2.0.0 v2.0.0 中添加

endomorphism   自同态

Signature 签名

export declare const endomorphism: typeof endomorphism

Added in v2.11.0 v2.11.0 中添加

identity   身份

Signature 签名

export declare const identity: typeof identity

Added in v2.0.0 v2.0.0 中添加

io   io

Signature 签名

export declare const io: typeof io

Added in v2.0.0 v2.0.0 中添加

ioEither   io要么

Signature 签名

export declare const ioEither: typeof ioEither

Added in v2.0.0 v2.0.0 中添加

ioOption   io选项

Signature 签名

export declare const ioOption: typeof ioOption

Added in v2.12.0 v2.12.0 中添加

map   地图

Signature 签名

export declare const map: typeof map

Added in v2.0.0 v2.0.0 中添加

nonEmptyArray   非空数组

Signature 签名

export declare const nonEmptyArray: typeof nonEmptyArray

Added in v2.0.0 v2.0.0 中添加

option   选项

Signature 签名

export declare const option: typeof option

Added in v2.0.0 v2.0.0 中添加

predicate   谓词

Signature 签名

export declare const predicate: typeof predicate

Added in v2.11.0 v2.11.0 中添加

reader   读者

Signature 签名

export declare const reader: typeof reader

Added in v2.0.0 v2.0.0 中添加

readerEither   读者要么

Signature 签名

export declare const readerEither: typeof readerEither

Added in v2.0.0 v2.0.0 中添加

readerIO   读者IO

Signature 签名

export declare const readerIO: typeof readerIO

Added in v2.0.0 v2.0.0 中添加

readerTask   读者任务

Signature 签名

export declare const readerTask: typeof readerTask

Added in v2.3.0 v2.3.0中添加

readerTaskEither   读者任务要么

Signature 签名

export declare const readerTaskEither: typeof readerTaskEither

Added in v2.0.0 v2.0.0 中添加

readonlyArray   只读数组

Signature 签名

export declare const readonlyArray: typeof readonlyArray

Added in v2.5.0 v2.5.0中添加

readonlyMap   只读地图

Signature 签名

export declare const readonlyMap: typeof readonlyMap

Added in v2.5.0 v2.5.0中添加

readonlyNonEmptyArray   只读非空数组

Signature 签名

export declare const readonlyNonEmptyArray: typeof readonlyNonEmptyArray

Added in v2.5.0 v2.5.0中添加

readonlyRecord   只读记录

Signature 签名

export declare const readonlyRecord: typeof readonlyRecord

Added in v2.5.0 v2.5.0中添加

readonlySet   只读集

Signature 签名

export declare const readonlySet: typeof readonlySet

Added in v2.5.0 v2.5.0中添加

readonlyTuple   只读元组

Signature 签名

export declare const readonlyTuple: typeof readonlyTuple

Added in v2.5.0 v2.5.0中添加

record   记录

Signature 签名

export declare const record: typeof record

Added in v2.0.0 v2.0.0 中添加

refinement   细化

Signature 签名

export declare const refinement: typeof refinement

Added in v2.11.0 v2.11.0 中添加

separated   分开

Signature 签名

export declare const separated: typeof separated

Added in v2.10.0 v2.10.0 中添加

set  

Signature 签名

export declare const set: typeof set

Added in v2.0.0 v2.0.0 中添加

state   状态

Signature 签名

export declare const state: typeof state

Added in v2.0.0 v2.0.0 中添加

stateReaderTaskEither   状态ReaderTaskEither

Signature 签名

export declare const stateReaderTaskEither: typeof stateReaderTaskEither

Added in v2.0.0 v2.0.0 中添加

store   店铺

Signature 签名

export declare const store: typeof store

Added in v2.0.0 v2.0.0 中添加

task   任务

Signature 签名

export declare const task: typeof task

Added in v2.0.0 v2.0.0 中添加

taskEither  任务要么

Signature 签名

export declare const taskEither: typeof taskEither

Added in v2.0.0 v2.0.0 中添加

taskOption  任务选项

Signature 签名

export declare const taskOption: typeof taskOption

Added in v2.10.0 v2.10.0 中添加

taskThese   任务这些

Signature 签名

export declare const taskThese: typeof taskThese

Added in v2.4.0 v2.4.0中添加

these   这些

Signature 签名

export declare const these: typeof these

Added in v2.0.0 v2.0.0 中添加

traced   追踪到的

Signature 签名

export declare const traced: typeof traced

Added in v2.0.0 v2.0.0 中添加

tree  

Signature 签名

export declare const tree: typeof tree

Added in v2.0.0 v2.0.0 中添加

tuple   元组

Signature 签名

export declare const tuple: typeof tuple

Added in v2.0.0 v2.0.0 中添加

validationT   验证T

Signature 签名

export declare const validationT: typeof validationT

Added in v2.0.0 v2.0.0 中添加

writer   作家

Signature 签名

export declare const writer: typeof writer

Added in v2.0.0 v2.0.0 中添加

model   模型

alt   替代

Signature 签名

export declare const alt: typeof alt

Added in v2.0.0 v2.0.0 中添加

alternative   选择

Signature 签名

export declare const alternative: typeof alternative

Added in v2.0.0 v2.0.0 中添加

applicative   应用性的

Signature 签名

export declare const applicative: typeof applicative

Added in v2.0.0 v2.0.0 中添加

apply   申请

Signature 签名

export declare const apply: typeof apply

Added in v2.0.0 v2.0.0 中添加

bifunctor   双函子

Signature 签名

export declare const bifunctor: typeof bifunctor

Added in v2.0.0 v2.0.0 中添加

booleanAlgebra   布尔代数

Signature 签名

export declare const booleanAlgebra: typeof booleanAlgebra

Added in v2.0.0 v2.0.0 中添加

bounded   有界的

Signature 签名

export declare const bounded: typeof bounded

Added in v2.0.0 v2.0.0 中添加

boundedDistributiveLattice
有界分配格

Signature 签名

export declare const boundedDistributiveLattice: typeof boundedDistributiveLattice

Added in v2.0.0 v2.0.0 中添加

boundedJoinSemilattice  有界连接半格

Signature 签名

export declare const boundedJoinSemilattice: typeof boundedJoinSemilattice

Added in v2.0.0 v2.0.0 中添加

boundedLattice   有界格

Signature 签名

export declare const boundedLattice: typeof boundedLattice

Added in v2.0.0 v2.0.0 中添加

boundedMeetSemilattice   有界相遇半格

Signature 签名

export declare const boundedMeetSemilattice: typeof boundedMeetSemilattice

Added in v2.0.0 v2.0.0 中添加

category   类别

Signature 签名

export declare const category: typeof category

Added in v2.0.0 v2.0.0 中添加

chain  

Signature 签名

export declare const chain: typeof chain

Added in v2.0.0 v2.0.0 中添加

chainRec   链记录

Signature 签名

export declare const chainRec: typeof chainRec

Added in v2.0.0 v2.0.0 中添加

choice   选择

Signature 签名

export declare const choice: typeof choice

Added in v2.0.0 v2.0.0 中添加

comonad   科莫纳德

Signature 签名

export declare const comonad: typeof comonad

Added in v2.0.0 v2.0.0 中添加

compactable   可压缩的

Signature 签名

export declare const compactable: typeof compactable

Added in v2.0.0 v2.0.0 中添加

contravariant  逆变

Signature 签名

export declare const contravariant: typeof contravariant

Added in v2.0.0 v2.0.0 中添加

distributiveLattice  分配格

Signature 签名

export declare const distributiveLattice: typeof distributiveLattice

Added in v2.0.0 v2.0.0 中添加

eq   情商

Signature 签名

export declare const eq: typeof eq

Added in v2.0.0 v2.0.0 中添加

extend   延长

Signature 签名

export declare const extend: typeof extend

Added in v2.0.0 v2.0.0 中添加

field   场地

Signature 签名

export declare const field: typeof field

Added in v2.0.0 v2.0.0 中添加

filterable   可过滤的

Signature 签名

export declare const filterable: typeof filterable

Added in v2.0.0 v2.0.0 中添加

filterableWithIndex   可过滤带索引

Signature 签名

export declare const filterableWithIndex: typeof filterableWithIndex

Added in v2.0.0 v2.0.0 中添加

foldable   折叠式

Signature 签名

export declare const foldable: typeof foldable

Added in v2.0.0 v2.0.0 中添加

foldableWithIndex   可折叠带索引

Signature 签名

export declare const foldableWithIndex: typeof foldableWithIndex

Added in v2.0.0 v2.0.0 中添加

fromEither   来自任一

Signature 签名

export declare const fromEither: typeof fromEither

Added in v2.10.0 v2.10.0 中添加

fromIO   来自IO

Signature 签名

export declare const fromIO: typeof fromIO

Added in v2.10.0 v2.10.0 中添加

fromReader   来自读者

Signature 签名

export declare const fromReader: typeof fromReader

Added in v2.11.0 v2.11.0 中添加

fromState   来自州

Signature 签名

export declare const fromState: typeof fromState

Added in v2.11.0 v2.11.0 中添加

fromTask   来自任务

Signature 签名

export declare const fromTask: typeof fromTask

Added in v2.10.0 v2.10.0 中添加

fromThese  来自这些

Signature 签名

export declare const fromThese: typeof fromThese

Added in v2.11.0 v2.11.0 中添加

functor  函子

Signature 签名

export declare const functor: typeof functor

Added in v2.0.0 v2.0.0 中添加

functorWithIndex   带索引的函子

Signature 签名

export declare const functorWithIndex: typeof functorWithIndex

Added in v2.0.0 v2.0.0 中添加

group   团体

Signature 签名

export declare const group: typeof group

Added in v2.0.0 v2.0.0 中添加

heytingAlgebra   海廷代数

Signature 签名

export declare const heytingAlgebra: typeof heytingAlgebra

Added in v2.0.0 v2.0.0 中添加

invariant   不变的

Signature 签名

export declare const invariant: typeof invariant

Added in v2.0.0 v2.0.0 中添加

joinSemilattice   加入半格子

Signature 签名

export declare const joinSemilattice: typeof joinSemilattice

Added in v2.0.0 v2.0.0 中添加

lattice   格子

Signature 签名

export declare const lattice: typeof lattice

Added in v2.0.0 v2.0.0 中添加

magma   岩浆

Signature 签名

export declare const magma: typeof magma

Added in v2.0.0 v2.0.0 中添加

meetSemilattice   遇见半格子

Signature 签名

export declare const meetSemilattice: typeof meetSemilattice

Added in v2.0.0 v2.0.0 中添加

monad   单子

Signature 签名

export declare const monad: typeof monad

Added in v2.0.0 v2.0.0 中添加

monadIO   蒙纳德奥

Signature 签名

export declare const monadIO: typeof monadIO

Added in v2.0.0 v2.0.0 中添加

monadTask  单子任务

Signature 签名

export declare const monadTask: typeof monadTask

Added in v2.0.0 v2.0.0 中添加

monadThrow  单子抛出

Signature 签名

export declare const monadThrow: typeof monadThrow

Added in v2.0.0 v2.0.0 中添加

monoid   幺半群

Signature 签名

export declare const monoid: typeof monoid

Added in v2.0.0 v2.0.0 中添加

ord   秩序

Signature 签名

export declare const ord: typeof ord

Added in v2.0.0 v2.0.0 中添加

pointed  

Signature 签名

export declare const pointed: typeof pointed

Added in v2.10.0 v2.10.0 中添加

profunctor   引子

Signature 签名

export declare const profunctor: typeof profunctor

Added in v2.0.0 v2.0.0 中添加

ring   戒指

Signature 签名

export declare const ring: typeof ring

Added in v2.0.0 v2.0.0 中添加

semigroup   半群

Signature 签名

export declare const semigroup: typeof semigroup

Added in v2.0.0 v2.0.0 中添加

semigroupoid   半群形

Signature 签名

export declare const semigroupoid: typeof semigroupoid

Added in v2.0.0 v2.0.0 中添加

semiring   半环

Signature 签名

export declare const semiring: typeof semiring

Added in v2.0.0 v2.0.0 中添加

show   展示

Signature 签名

export declare const show: typeof show

Added in v2.0.0 v2.0.0 中添加

strong   强的

Signature 签名

export declare const strong: typeof strong

Added in v2.0.0 v2.0.0 中添加

traversable   可穿越的

Signature 签名

export declare const traversable: typeof traversable

Added in v2.0.0 v2.0.0 中添加

traversableWithIndex   可遍历索引

Signature 签名

export declare const traversableWithIndex: typeof traversableWithIndex

Added in v2.0.0 v2.0.0 中添加

unfoldable   可展开的

Signature 签名

export declare const unfoldable: typeof unfoldable

Added in v2.0.0 v2.0.0 中添加

witherable   枯萎的

Signature 签名

export declare const witherable: typeof witherable

Added in v2.0.0 v2.0.0 中添加

zero  

Signature 签名

export declare const zero: typeof zero

Added in v2.11.0 v2.11.0 中添加

monad transformers   单子变压器

eitherT   要么T

Signature 签名

export declare const eitherT: typeof eitherT

Added in v2.0.0 v2.0.0 中添加

optionT   选项T

Signature 签名

export declare const optionT: typeof optionT

Added in v2.0.0 v2.0.0 中添加

readerT   读者T

Signature 签名

export declare const readerT: typeof readerT

Added in v2.0.0 v2.0.0 中添加

stateT   状态T

Signature 签名

export declare const stateT: typeof stateT

Added in v2.0.0 v2.0.0 中添加

theseT   这些T

Signature 签名

export declare const theseT: typeof theseT

Added in v2.4.0 v2.4.0中添加

writerT   作家T

Signature 签名

export declare const writerT: typeof writerT

Added in v2.4.0 v2.4.0中添加

utils   实用程序

boolean   布尔值

Signature 签名

export declare const boolean: typeof boolean

Added in v2.2.0 v2.2.0中添加

console   安慰

Signature 签名

export declare const console: typeof console

Added in v2.0.0 v2.0.0 中添加

date   日期

Signature 签名

export declare const date: typeof date

Added in v2.0.0 v2.0.0 中添加

function   功能

Signature 签名

export declare const function: typeof function_

Added in v2.0.0 v2.0.0 中添加

hkt   香港电讯

Signature 签名

export declare const hkt: typeof hkt

Added in v2.0.0 v2.0.0 中添加

ioRef   参考号

Signature 签名

export declare const ioRef: typeof ioRef

Added in v2.0.0 v2.0.0 中添加

json   json

Signature 签名

export declare const json: typeof json

Added in v2.10.0 v2.10.0 中添加

naturalTransformation   自然转变

Signature 签名

export declare const naturalTransformation: typeof naturalTransformation

Added in v2.11.0 v2.11.0 中添加

number   数字

Signature 签名

export declare const number: typeof number

Added in v2.10.0 v2.10.0 中添加

ordering   订购

Signature 签名

export declare const ordering: typeof ordering

Added in v2.0.0 v2.0.0 中添加

pipeable   可管道化的

Signature 签名

export declare const pipeable: typeof pipeable

Added in v2.0.0 v2.0.0 中添加

random   随机的

Signature 签名

export declare const random: typeof random

Added in v2.0.0 v2.0.0 中添加

string   细绳

Signature 签名

export declare const string: typeof string

Added in v2.10.0 v2.10.0 中添加

struct   结构体

Signature 签名

export declare const struct: typeof struct

Added in v2.10.0 v2.10.0 中添加

zone of death
死亡地带

void 空白

Signature 签名

export declare const void: typeof void_

Added in v2.11.0 v2.11.0 中添加

Invariant overview  不变概述

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Invariant (interface)   不变式(接口)

Signature 签名

export interface Invariant<F> {
  readonly URI: F
  readonly imap: <A, B>(fa: HKT<F, A>, f: (a: A) => B, g: (b: B) => A) => HKT<F, B>
}

Added in v2.0.0 v2.0.0 中添加

Invariant1 (interface)   不变式1(接口)

Signature 签名

export interface Invariant1<F extends URIS> {
  readonly URI: F
  readonly imap: <A, B>(fa: Kind<F, A>, f: (a: A) => B, g: (b: B) => A) => Kind<F, B>
}

Added in v2.0.0 v2.0.0 中添加

Invariant2 (interface)   不变2(接口)

Signature 签名

export interface Invariant2<F extends URIS2> {
  readonly URI: F
  readonly imap: <E, A, B>(fa: Kind2<F, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

Invariant2C (interface)
Invariant2C(接口)

Signature 签名

export interface Invariant2C<F extends URIS2, E> {
  readonly URI: F
  readonly _E: E
  readonly imap: <A, B>(fa: Kind2<F, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

Invariant3 (interface)   不变3(接口)

Signature 签名

export interface Invariant3<F extends URIS3> {
  readonly URI: F
  readonly imap: <R, E, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind3<F, R, E, B>
}

Added in v2.0.0 v2.0.0 中添加

Invariant3C (interface)
Invariant3C(接口)

Signature 签名

export interface Invariant3C<F extends URIS3, E> {
  readonly URI: F
  readonly _E: E
  readonly imap: <R, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind3<F, R, E, B>
}

Added in v2.4.2 v2.4.2 中添加

Invariant4 (interface)   不变式4(接口)

Signature 签名

export interface Invariant4<F extends URIS4> {
  readonly URI: F
  readonly imap: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind4<F, S, R, E, B>
}

Added in v2.4.2 v2.4.2 中添加

IO overview  IO概述

interface IO<A> {
  (): A
}

IO<A> represents a non-deterministic synchronous computation that can cause side effects, yields a value of type A and never fails.
IO<A> 表示非确定性同步计算,可能会导致副作用,产生 A 类型的值并且永远不会失败。

If you want to represent a synchronous computation that may fail, please see IOEither. If you want to represent a synchronous computation that may yield nothing, please see IOOption.
如果你想表示一个可能失败的同步计算,请参见 IOEither 。如果您想表示可能不会产生任何结果的同步计算,请参阅 IOOption

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


combinators   组合器

tap   轻敲

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tap: {
  <A, _>(self: IO<A>, f: (a: A) => IO<_>): IO<A>
  <A, _>(f: (a: A) => IO<_>): (self: IO<A>) => IO<A>
}

Added in v2.15.0 v2.15.0 中添加

constructors  构造函数

of  

Signature 签名

export declare const of: <A>(a: A) => IO<A>

Added in v2.0.0 v2.0.0 中添加

do notation   做记号

Do  

Signature 签名

export declare const Do: IO<{}>

Added in v2.9.0 v2.9.0中添加

apS   apS

Signature 签名

export declare const apS: <N, A, B>(
  name: Exclude<N, keyof A>,
  fb: IO<B>
) => (fa: IO<A>) => IO<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bind   绑定

Signature 签名

export declare const bind: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => IO<B>
) => (ma: IO<A>) => IO<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bindTo   绑定到

Signature 签名

export declare const bindTo: <N>(name: N) => <A>(fa: IO<A>) => IO<{ readonly [K in N]: A }>

Added in v2.8.0 v2.8.0 中添加

let  

Signature 签名

export declare const let: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => (fa: IO<A>) => IO<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.13.0 v2.13.0 中添加

instances   实例

Applicative   适用性

Signature 签名

export declare const Applicative: Applicative1<'IO'>

Added in v2.7.0 v2.7.0 中添加

Apply   申请

Signature 签名

export declare const Apply: Apply1<'IO'>

Added in v2.10.0 v2.10.0 中添加

Chain  

Signature 签名

export declare const Chain: chainable.Chain1<'IO'>

Added in v2.10.0 v2.10.0 中添加

ChainRec   链录

Signature 签名

export declare const ChainRec: ChainRec1<'IO'>

Added in v2.7.0 v2.7.0 中添加

FromIO   来自IO

Signature 签名

export declare const FromIO: FromIO1<'IO'>

Added in v2.10.0 v2.10.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor1<'IO'>

Added in v2.7.0 v2.7.0 中添加

Monad   单子

Signature 签名

export declare const Monad: Monad1<'IO'>

Added in v2.7.0 v2.7.0 中添加

MonadIO   莫纳德奥

Signature 签名

export declare const MonadIO: MonadIO1<'IO'>

Added in v2.7.0 v2.7.0 中添加

Pointed  

Signature 签名

export declare const Pointed: Pointed1<'IO'>

Added in v2.10.0 v2.10.0 中添加

legacy   遗产

chain  

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chain: <A, B>(f: (a: A) => IO<B>) => (ma: IO<A>) => IO<B>

Added in v2.0.0 v2.0.0 中添加

chainFirst   链优先

Alias of tap.  tap 的别名。

Signature 签名

export declare const chainFirst: <A, B>(f: (a: A) => IO<B>) => (first: IO<A>) => IO<A>

Added in v2.0.0 v2.0.0 中添加

mapping   映射

as   作为

Maps the value to the specified constant value.
将值映射到指定的常量值。

Signature 签名

export declare const as: { <A>(a: A): <_>(self: IO<_>) => IO<A>; <_, A>(self: IO<_>, a: A): IO<A> }

Added in v2.16.0 v2.16.0 中添加

asUnit   作为单位

Maps the value to the void constant value.
将值映射到 void 常量值。

Signature 签名

export declare const asUnit: <_>(self: IO<_>) => IO<void>

Added in v2.16.0 v2.16.0 中添加

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <B>(fab: IO<(a: A) => B>) => IO<B>

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => (fa: IO<A>) => IO<B>

Added in v2.0.0 v2.0.0 中添加

model   模型

IO (interface)   IO(接口)

Signature 签名

export interface IO<A> {
  (): A
}

Added in v2.0.0 v2.0.0 中添加

sequencing   测序

flatMap   平面地图

Signature 签名

export declare const flatMap: {
  <A, B>(f: (a: A) => IO<B>): (ma: IO<A>) => IO<B>
  <A, B>(ma: IO<A>, f: (a: A) => IO<B>): IO<B>
}

Added in v2.14.0 v2.14.0 中添加

flatten   压扁

Signature 签名

export declare const flatten: <A>(mma: IO<IO<A>>) => IO<A>

Added in v2.0.0 v2.0.0 中添加

traversing   穿越

sequenceArray   序列数组

Equivalent to ReadonlyArray#sequence(Applicative). 相当于 ReadonlyArray#sequence(Applicative)

Signature 签名

export declare const sequenceArray: <A>(arr: readonly IO<A>[]) => IO<readonly A[]>

Added in v2.9.0 v2.9.0中添加

traverseArray   遍历数组

Equivalent to ReadonlyArray#traverse(Applicative). 相当于 ReadonlyArray#traverse(Applicative)

Signature 签名

export declare const traverseArray: <A, B>(f: (a: A) => IO<B>) => (as: readonly A[]) => IO<readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseArrayWithIndex   带索引遍历数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseArrayWithIndex: <A, B>(
  f: (index: number, a: A) => IO<B>
) => (as: readonly A[]) => IO<readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseReadonlyArrayWithIndex
遍历带索引的只读数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseReadonlyArrayWithIndex: <A, B>(
  f: (index: number, a: A) => IO<B>
) => (as: readonly A[]) => IO<readonly B[]>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyNonEmptyArrayWithIndex
遍历ReadonlyNonEmptyArrayWithIndex

Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(Applicative). 相当于 ReadonlyNonEmptyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseReadonlyNonEmptyArrayWithIndex: <A, B>(
  f: (index: number, a: A) => IO<B>
) => (as: ReadonlyNonEmptyArray<A>) => IO<ReadonlyNonEmptyArray<B>>

Added in v2.11.0 v2.11.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'IO'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

ApT   易于

Signature 签名

export declare const ApT: IO<readonly []>

Added in v2.11.0 v2.11.0 中添加

ap   美联社

Signature 签名

export declare const ap: <A>(fa: IO<A>) => <B>(fab: IO<(a: A) => B>) => IO<B>

Added in v2.0.0 v2.0.0 中添加

apFirst   应用程序第一

Combine two effectful actions, keeping only the result of the first.
结合两个有效的操作,仅保留第一个操作的结果。

Signature 签名

export declare const apFirst: <B>(second: IO<B>) => <A>(first: IO<A>) => IO<A>

Added in v2.0.0 v2.0.0 中添加

apSecond   ap秒

Combine two effectful actions, keeping only the result of the second.
结合两个有效的操作,只保留第二个的结果。

Signature 签名

export declare const apSecond: <B>(second: IO<B>) => <A>(first: IO<A>) => IO<B>

Added in v2.0.0 v2.0.0 中添加

zone of death
死亡地带

fromIO 来自IO

Signature 签名

export declare const fromIO: <A>(fa: IO<A>) => IO<A>

Added in v2.7.0 v2.7.0 中添加

getMonoid 获取Monoid

Use getApplicativeMonoid instead. 请改用 getApplicativeMonoid

Signature 签名

export declare const getMonoid: <A>(M: Monoid<A>) => Monoid<IO<A>>

Added in v2.0.0 v2.0.0 中添加

getSemigroup 获取半群

Use getApplySemigroup instead. 请改用 getApplySemigroup

Signature 签名

export declare const getSemigroup: <A>(S: Semigroup<A>) => Semigroup<IO<A>>

Added in v2.0.0 v2.0.0 中添加

io io

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass IO.Functor instead of IO.io (where IO is from import IO from 'fp-ts/IO')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 IO.Functor 而不是 IO.io (其中 IO 来自 import IO from 'fp-ts/IO'

Signature 签名

export declare const io: Monad1<'IO'> & MonadIO1<'IO'> & ChainRec1<'IO'>

Added in v2.0.0 v2.0.0 中添加

IOEither overview  IO任一概述

IOEither<E, A> represents a synchronous computation that either yields a value of type A or fails yielding an error of type E.
IOEither<E, A> 表示同步计算,它要么生成 A 类型的值,要么失败并生成 E 类型的错误。

If you want to represent a synchronous computation that never fails, please see IO. If you want to represent a synchronous computation that may yield nothing, please see IOOption.
如果你想表示永不失败的同步计算,请参阅 IO 。如果您想表示可能不会产生任何结果的同步计算,请参阅 IOOption

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


combinators   组合器

tap   轻敲

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tap: {
  <E1, A, E2, _>(self: IOEither<E1, A>, f: (a: A) => IOEither<E2, _>): IOEither<E1 | E2, A>
  <A, E2, _>(f: (a: A) => IOEither<E2, _>): <E1>(self: IOEither<E1, A>) => IOEither<E2 | E1, A>
}

Added in v2.15.0 v2.15.0 中添加

tapEither   点击任一

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapEither: {
  <A, E2, _>(f: (a: A) => E.Either<E2, _>): <E1>(self: IOEither<E1, A>) => IOEither<E2 | E1, A>
  <E1, A, E2, _>(self: IOEither<E1, A>, f: (a: A) => E.Either<E2, _>): IOEither<E1 | E2, A>
}

Example 例子

import { pipe } from 'fp-ts/function'
import * as IOE from 'fp-ts/IOEither'
import * as E from 'fp-ts/Either'

const compute = (value: string) =>
  pipe(
    IOE.of(value),
    IOE.tapEither(() => (value.length > 0 ? E.right('ok') : E.left('error')))
  )

assert.deepStrictEqual(compute('')(), E.left('error'))
assert.deepStrictEqual(compute('fp-ts')(), E.right('fp-ts'))

Added in v2.16.0 v2.16.0 中添加

tapIO   tapIO

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapIO: {
  <A, _>(f: (a: A) => I.IO<_>): <E>(self: IOEither<E, A>) => IOEither<E, A>
  <E, A, _>(self: IOEither<E, A>, f: (a: A) => I.IO<_>): IOEither<E, A>
}

Example 例子

import { pipe } from 'fp-ts/function'
import * as IOE from 'fp-ts/IOEither'
import * as E from 'fp-ts/Either'
import * as Console from 'fp-ts/Console'

const sayHello = (value: string) => Console.log(`Hello, ${value}`)

// Will produce `Hello, fp-ts` to the stdout
const effectA = IOE.tapIO(IOE.of('fp-ts'), sayHello)

// No output to the stdout
const effectB = pipe(IOE.left<string>('error'), IOE.tapIO(sayHello))

assert.deepStrictEqual(effectA(), E.right('fp-ts'))
assert.deepStrictEqual(effectB(), E.left('error'))

Added in v2.16.0 v2.16.0 中添加

constructors  构造函数

left  左边

Signature 签名

export declare const left: <E = never, A = never>(l: E) => IOEither<E, A>

Added in v2.0.0 v2.0.0 中添加

leftIO   左IO

Signature 签名

export declare const leftIO: <E = never, A = never>(me: I.IO<E>) => IOEither<E, A>

Added in v2.0.0 v2.0.0 中添加

of  

Signature 签名

export declare const of: <E = never, A = never>(a: A) => IOEither<E, A>

Added in v2.8.5 v2.8.5 中添加

Signature 签名

export declare const right: <E = never, A = never>(a: A) => IOEither<E, A>

Added in v2.0.0 v2.0.0 中添加

rightIO   右IO

Signature 签名

export declare const rightIO: <E = never, A = never>(ma: I.IO<A>) => IOEither<E, A>

Added in v2.0.0 v2.0.0 中添加

conversions   转换

fromEither   来自任一

Signature 签名

export declare const fromEither: <E, A>(fa: E.Either<E, A>) => IOEither<E, A>

Added in v2.0.0 v2.0.0 中添加

fromIO   来自IO

Signature 签名

export declare const fromIO: <A, E = never>(fa: I.IO<A>) => IOEither<E, A>

Added in v2.7.0 v2.7.0 中添加

fromOption   来自选项

Signature 签名

export declare const fromOption: <E>(onNone: LazyArg<E>) => <A>(fa: Option<A>) => IOEither<E, A>

Added in v2.0.0 v2.0.0 中添加

toUnion   至联盟

Signature 签名

export declare const toUnion: <E, A>(fa: IOEither<E, A>) => I.IO<E | A>

Added in v2.10.0 v2.10.0 中添加

do notation   做记号

Do  

Signature 签名

export declare const Do: IOEither<never, {}>

Added in v2.9.0 v2.9.0中添加

apS   apS

Signature 签名

export declare const apS: <N, A, E, B>(
  name: Exclude<N, keyof A>,
  fb: IOEither<E, B>
) => (fa: IOEither<E, A>) => IOEither<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

apSW   apSW

Less strict version of apS.
apS 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const apSW: <A, N extends string, E2, B>(
  name: Exclude<N, keyof A>,
  fb: IOEither<E2, B>
) => <E1>(fa: IOEither<E1, A>) => IOEither<E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bind   绑定

Signature 签名

export declare const bind: <N, A, E, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => IOEither<E, B>
) => (ma: IOEither<E, A>) => IOEither<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bindTo   绑定到

Signature 签名

export declare const bindTo: <N>(name: N) => <E, A>(fa: IOEither<E, A>) => IOEither<E, { readonly [K in N]: A }>

Added in v2.8.0 v2.8.0 中添加

bindW   绑定W

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const bindW: <N extends string, A, E2, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => IOEither<E2, B>
) => <E1>(fa: IOEither<E1, A>) => IOEither<E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

let  

Signature 签名

export declare const let: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => <E>(fa: IOEither<E, A>) => IOEither<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.13.0 v2.13.0 中添加

error handling   错误处理

alt   替代

Identifies an associative operation on a type constructor. It is similar to Semigroup, except that it applies to types of kind * -> *.
标识类型构造函数上的关联操作。它与 Semigroup 类似,但它适用于 * -> * 类型。

Signature 签名

export declare const alt: <E, A>(that: LazyArg<IOEither<E, A>>) => (fa: IOEither<E, A>) => IOEither<E, A>

Added in v2.0.0 v2.0.0 中添加

altW   替代W

Less strict version of alt.
alt 的不太严格版本。

The W suffix (short for Widening) means that the error and the return types will be merged.
W 后缀(Widening 的缩写)意味着错误和返回类型将被合并。

Signature 签名

export declare const altW: <E2, B>(
  that: LazyArg<IOEither<E2, B>>
) => <E1, A>(fa: IOEither<E1, A>) => IOEither<E2, B | A>

Added in v2.9.0 v2.9.0中添加

getAltIOValidation   获取AltIO验证

The default Alt instance returns the last error, if you want to get all errors you need to provide a way to concatenate them via a Semigroup.
默认的 Alt 实例返回最后一个错误,如果你想获取所有错误,你需要提供一种通过 Semigroup 连接它们的方法。

See getAltValidation. 请参阅 getAltValidation

Signature 签名

export declare function getAltIOValidation<E>(S: Semigroup<E>): Alt2C<URI, E>

Added in v2.7.0 v2.7.0 中添加

getApplicativeIOValidation
获取ApplicativeIOValidation

The default ApplicativePar instance returns the first error, if you want to get all errors you need to provide a way to concatenate them via a Semigroup.
默认的 ApplicativePar 实例返回第一个错误,如果您想获取所有错误,您需要提供一种通过 Semigroup 连接它们的方法。

See getApplicativeValidation. 请参阅 getApplicativeValidation

Signature 签名

export declare function getApplicativeIOValidation<E>(S: Semigroup<E>): Applicative2C<URI, E>

Added in v2.7.0 v2.7.0 中添加

getOrElse  获取或否则

Signature 签名

export declare const getOrElse: <E, A>(onLeft: (e: E) => I.IO<A>) => (ma: IOEither<E, A>) => I.IO<A>

Added in v2.0.0 v2.0.0 中添加

getOrElseW   获取或否则W

Less strict version of getOrElse.
getOrElse 的不太严格版本。

The W suffix (short for Widening) means that the handler return type will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const getOrElseW: <E, B>(onLeft: (e: E) => I.IO<B>) => <A>(ma: IOEither<E, A>) => I.IO<B | A>

Added in v2.6.0 v2.6.0 中添加

mapBoth   地图两者

Returns a IOEither whose failure and success channels have been mapped by the specified pair of functions, f and g.
返回一个 IOEither ,其失败和成功通道已由指定的函数对 fg 映射。

Signature 签名

export declare const mapBoth: {
  <E, G, A, B>(f: (e: E) => G, g: (a: A) => B): (self: IOEither<E, A>) => IOEither<G, B>
  <E, A, G, B>(self: IOEither<E, A>, f: (e: E) => G, g: (a: A) => B): IOEither<G, B>
}

Example 例子

import * as IOEither from 'fp-ts/IOEither'
import * as Either from 'fp-ts/Either'

const f = (s: string) => new Error(s)
const g = (n: number) => n * 2

assert.deepStrictEqual(IOEither.mapBoth(IOEither.right(1), f, g)(), Either.right(2))
assert.deepStrictEqual(IOEither.mapBoth(IOEither.left('err'), f, g)(), Either.left(new Error('err')))

Added in v2.16.0 v2.16.0 中添加

mapError   地图错误

Returns a IOEither with its error channel mapped using the specified function.
返回 IOEither 及其使用指定函数映射的错误通道。

Signature 签名

export declare const mapError: {
  <E, G>(f: (e: E) => G): <A>(self: IOEither<E, A>) => IOEither<G, A>
  <E, A, G>(self: IOEither<E, A>, f: (e: E) => G): IOEither<G, A>
}

Example 例子

import * as IOEither from 'fp-ts/IOEither'
import * as Either from 'fp-ts/Either'

const f = (s: string) => new Error(s)

assert.deepStrictEqual(IOEither.mapError(IOEither.right(1), f)(), Either.right(1))
assert.deepStrictEqual(IOEither.mapError(IOEither.left('err'), f)(), Either.left(new Error('err')))

Added in v2.16.0 v2.16.0 中添加

orElse   要不然

Signature 签名

export declare const orElse: <E1, A, E2>(onLeft: (e: E1) => IOEither<E2, A>) => (ma: IOEither<E1, A>) => IOEither<E2, A>

Added in v2.0.0 v2.0.0 中添加

orElseFirstIOK   否则先IOK

Signature 签名

export declare const orElseFirstIOK: <E, B>(onLeft: (e: E) => I.IO<B>) => <A>(ma: IOEither<E, A>) => IOEither<E, A>

Added in v2.12.0 v2.12.0 中添加

orElseW   否则W

Less strict version of orElse.
orElse 的不太严格版本。

The W suffix (short for Widening) means that the return types will be merged.
W 后缀(Widening 的缩写)意味着返回类型将被合并。

Signature 签名

export declare const orElseW: <E1, E2, B>(
  onLeft: (e: E1) => IOEither<E2, B>
) => <A>(ma: IOEither<E1, A>) => IOEither<E2, B | A>

Added in v2.10.0 v2.10.0 中添加

orLeft   或向左

Signature 签名

export declare const orLeft: <E1, E2>(onLeft: (e: E1) => I.IO<E2>) => <A>(fa: IOEither<E1, A>) => IOEither<E2, A>

Added in v2.11.0 v2.11.0 中添加

tapError   点击错误

Returns an effect that effectfully “peeks” at the failure of this effect.
返回一个效果,有效地“窥视”此效果的失败。

Signature 签名

export declare const tapError: {
  <E1, E2, _>(onLeft: (e: E1) => IOEither<E2, _>): <A>(self: IOEither<E1, A>) => IOEither<E1 | E2, A>
  <E1, A, E2, _>(self: IOEither<E1, A>, onLeft: (e: E1) => IOEither<E2, _>): IOEither<E1 | E2, A>
}

Added in v2.15.0 v2.15.0 中添加

filtering   过滤

filterOrElse  过滤器或者其他

Signature 签名

export declare const filterOrElse: {
  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: IOEither<E, A>) => IOEither<E, B>
  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(mb: IOEither<E, B>) => IOEither<E, B>
  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: IOEither<E, A>) => IOEither<E, A>
}

Added in v2.0.0 v2.0.0 中添加

filterOrElseW   过滤器否则W

Less strict version of filterOrElse.
filterOrElse 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const filterOrElseW: {
  <A, B extends A, E2>(refinement: Refinement<A, B>, onFalse: (a: A) => E2): <E1>(
    ma: IOEither<E1, A>
  ) => IOEither<E2 | E1, B>
  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <E1, B extends A>(
    mb: IOEither<E1, B>
  ) => IOEither<E2 | E1, B>
  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <E1>(ma: IOEither<E1, A>) => IOEither<E2 | E1, A>
}

Added in v2.9.0 v2.9.0中添加

getCompactable   获取可压缩的

Signature 签名

export declare const getCompactable: <E>(M: Monoid<E>) => Compactable2C<'IOEither', E>

Added in v2.10.0 v2.10.0 中添加

getFilterable   获取可过滤的

Signature 签名

export declare function getFilterable<E>(M: Monoid<E>): Filterable2C<URI, E>

Added in v2.1.0 v2.1.0中添加

instances   实例

Alt   替代

Signature 签名

export declare const Alt: Alt2<'IOEither'>

Added in v2.7.0 v2.7.0 中添加

ApplicativePar   应用性参数

Runs computations in parallel.
并行运行计算。

Signature 签名

export declare const ApplicativePar: Applicative2<'IOEither'>

Added in v2.8.4 v2.8.4 中添加

ApplicativeSeq   应用序列

Runs computations sequentially.
按顺序运行计算。

Signature 签名

export declare const ApplicativeSeq: Applicative2<'IOEither'>

Added in v2.8.4 v2.8.4 中添加

ApplyPar   申请帕

Runs computations in parallel.
并行运行计算。

Signature 签名

export declare const ApplyPar: Apply2<'IOEither'>

Added in v2.10.0 v2.10.0 中添加

Bifunctor   双函子

Signature 签名

export declare const Bifunctor: Bifunctor2<'IOEither'>

Added in v2.7.0 v2.7.0 中添加

Chain  

Signature 签名

export declare const Chain: chainable.Chain2<'IOEither'>

Added in v2.10.0 v2.10.0 中添加

FromEither   来自任一

Signature 签名

export declare const FromEither: FromEither2<'IOEither'>

Added in v2.10.0 v2.10.0 中添加

FromIO   来自IO

Signature 签名

export declare const FromIO: FromIO2<'IOEither'>

Added in v2.10.0 v2.10.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor2<'IOEither'>

Added in v2.7.0 v2.7.0 中添加

Monad   单子

Signature 签名

export declare const Monad: Monad2<'IOEither'>

Added in v2.7.0 v2.7.0 中添加

MonadIO   莫纳德奥

Signature 签名

export declare const MonadIO: MonadIO2<'IOEither'>

Added in v2.7.0 v2.7.0 中添加

MonadThrow   单子投掷

Signature 签名

export declare const MonadThrow: MonadThrow2<'IOEither'>

Added in v2.7.0 v2.7.0 中添加

Pointed  

Signature 签名

export declare const Pointed: Pointed2<'IOEither'>

Added in v2.10.0 v2.10.0 中添加

interop   互操作

tryCatch   试着抓

Constructs a new IOEither from a function that performs a side effect and might throw
从执行副作用并可能抛出异常的函数构造一个新的 IOEither

See also tryCatchK. 另请参阅 tryCatchK

Signature 签名

export declare const tryCatch: <E, A>(f: LazyArg<A>, onThrow: (reason: unknown) => E) => IOEither<E, A>

Added in v2.0.0 v2.0.0 中添加

tryCatchK   尝试捕获K

Converts a function that may throw to one returning a IOEither.
将可能抛出异常的函数转换为返回 IOEither 的函数。

Signature 签名

export declare const tryCatchK: <A extends readonly unknown[], B, E>(
  f: (...a: A) => B,
  onThrow: (reason: unknown) => E
) => (...a: A) => IOEither<E, B>

Added in v2.10.0 v2.10.0 中添加

legacy   遗产

bimap   双图

Alias of mapBoth.  mapBoth 的别名。

Signature 签名

export declare const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: IOEither<E, A>) => IOEither<G, B>

Added in v2.0.0 v2.0.0 中添加

chain  

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chain: <E, A, B>(f: (a: A) => IOEither<E, B>) => (ma: IOEither<E, A>) => IOEither<E, B>

Added in v2.0.0 v2.0.0 中添加

chainEitherK  链EiK

Alias of flatMapEither.  flatMapEither 的别名。

Signature 签名

export declare const chainEitherK: <E, A, B>(f: (a: A) => E.Either<E, B>) => (ma: IOEither<E, A>) => IOEither<E, B>

Added in v2.4.0 v2.4.0中添加

chainEitherKW  链条任一KW

Alias of flatMapEither.  flatMapEither 的别名。

Signature 签名

export declare const chainEitherKW: <E2, A, B>(
  f: (a: A) => E.Either<E2, B>
) => <E1>(ma: IOEither<E1, A>) => IOEither<E2 | E1, B>

Added in v2.6.1 v2.6.1 中添加

chainFirst   链优先

Alias of tap.  tap 的别名。

Signature 签名

export declare const chainFirst: <E, A, B>(f: (a: A) => IOEither<E, B>) => (ma: IOEither<E, A>) => IOEither<E, A>

Added in v2.0.0 v2.0.0 中添加

chainFirstEitherK  链FirstEiK

Alias of tapEither.  tapEither 的别名。

Signature 签名

export declare const chainFirstEitherK: <A, E, B>(f: (a: A) => E.Either<E, B>) => (ma: IOEither<E, A>) => IOEither<E, A>

Added in v2.12.0 v2.12.0 中添加

chainFirstEitherKW   链FirstEiKW

Alias of tapEither.  tapEither 的别名。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const chainFirstEitherKW: <A, E2, B>(
  f: (a: A) => E.Either<E2, B>
) => <E1>(ma: IOEither<E1, A>) => IOEither<E2 | E1, A>

Added in v2.12.0 v2.12.0 中添加

chainFirstIOK  链第一IOK

Alias of tapIO.  tapIO 的别名。

Signature 签名

export declare const chainFirstIOK: <A, B>(f: (a: A) => I.IO<B>) => <E>(first: IOEither<E, A>) => IOEither<E, A>

Added in v2.10.0 v2.10.0 中添加

chainFirstW  链优先W

Alias of tap.  tap 的别名。

Signature 签名

export declare const chainFirstW: <E2, A, B>(
  f: (a: A) => IOEither<E2, B>
) => <E1>(ma: IOEither<E1, A>) => IOEither<E2 | E1, A>

Added in v2.8.0 v2.8.0 中添加

chainIOK  链IOK

Alias of flatMapIO.  flatMapIO 的别名。

Signature 签名

export declare const chainIOK: <A, B>(f: (a: A) => I.IO<B>) => <E>(first: IOEither<E, A>) => IOEither<E, B>

Added in v2.10.0 v2.10.0 中添加

chainOptionK   链选项K

Use flatMapOption. 使用 flatMapOption

Signature 签名

export declare const chainOptionK: <E>(
  onNone: LazyArg<E>
) => <A, B>(f: (a: A) => Option<B>) => (ma: IOEither<E, A>) => IOEither<E, B>

Added in v2.10.0 v2.10.0 中添加

chainOptionKW   链条选项KW

Use flatMapOption. 使用 flatMapOption

Signature 签名

export declare const chainOptionKW: <E2>(
  onNone: LazyArg<E2>
) => <A, B>(f: (a: A) => Option<B>) => <E1>(ma: IOEither<E1, A>) => IOEither<E2 | E1, B>

Added in v2.13.2 v2.13.2 中添加

chainW   链W

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chainW: <E2, A, B>(
  f: (a: A) => IOEither<E2, B>
) => <E1>(ma: IOEither<E1, A>) => IOEither<E2 | E1, B>

Added in v2.6.0 v2.6.0 中添加

fromOptionK   来自选项K

Use liftOption. 使用 liftOption

Signature 签名

export declare const fromOptionK: <E>(
  onNone: LazyArg<E>
) => <A extends readonly unknown[], B>(f: (...a: A) => Option<B>) => (...a: A) => IOEither<E, B>

Added in v2.10.0 v2.10.0 中添加

mapLeft   地图左

Alias of mapError.  mapError 的别名。

Signature 签名

export declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: IOEither<E, A>) => IOEither<G, A>

Added in v2.0.0 v2.0.0 中添加

orElseFirst   或其他优先

Alias of tapError.  tapError 的别名。

Signature 签名

export declare const orElseFirst: <E, B>(onLeft: (e: E) => IOEither<E, B>) => <A>(ma: IOEither<E, A>) => IOEither<E, A>

Added in v2.11.0 v2.11.0 中添加

orElseFirstW   否则先W

Alias of tapError.  tapError 的别名。

Signature 签名

export declare const orElseFirstW: <E1, E2, B>(
  onLeft: (e: E1) => IOEither<E2, B>
) => <A>(ma: IOEither<E1, A>) => IOEither<E1 | E2, A>

Added in v2.11.0 v2.11.0 中添加

lifting   起重

fromEitherK   来自EitherK

Signature 签名

export declare const fromEitherK: <E, A extends readonly unknown[], B>(
  f: (...a: A) => E.Either<E, B>
) => (...a: A) => IOEither<E, B>

Added in v2.4.0 v2.4.0中添加

fromIOK   来自IOK

Signature 签名

export declare const fromIOK: <A extends readonly unknown[], B>(
  f: (...a: A) => I.IO<B>
) => <E = never>(...a: A) => IOEither<E, B>

Added in v2.10.0 v2.10.0 中添加

fromPredicate   来自谓词

Signature 签名

export declare const fromPredicate: {
  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => IOEither<E, B>
  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => IOEither<E, B>
  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => IOEither<E, A>
}

Added in v2.0.0 v2.0.0 中添加

liftNullable   提升可为空

Signature 签名

export declare const liftNullable: <A extends readonly unknown[], B, E>(
  f: (...a: A) => B | null | undefined,
  onNullable: (...a: A) => E
) => (...a: A) => IOEither<E, NonNullable<B>>

Added in v2.15.0 v2.15.0 中添加

liftOption   电梯选项

Signature 签名

export declare const liftOption: <A extends readonly unknown[], B, E>(
  f: (...a: A) => Option<B>,
  onNone: (...a: A) => E
) => (...a: A) => IOEither<E, B>

Added in v2.15.0 v2.15.0 中添加

mapping   映射

as   作为

Maps the Right value of this IOEither to the specified constant value.
将此 IOEitherRight 值映射到指定的常量值。

Signature 签名

export declare const as: {
  <A>(a: A): <E, _>(self: IOEither<E, _>) => IOEither<E, A>
  <E, _, A>(self: IOEither<E, _>, a: A): IOEither<E, A>
}

Added in v2.16.0 v2.16.0 中添加

asUnit   作为单位

Maps the Right value of this IOEither to the void constant value.
将此 IOEitherRight 值映射到void 常量值。

Signature 签名

export declare const asUnit: <E, _>(self: IOEither<E, _>) => IOEither<E, void>

Added in v2.16.0 v2.16.0 中添加

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <E, B>(fab: IOEither<E, (a: A) => B>) => IOEither<E, B>

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => <E>(fa: IOEither<E, A>) => IOEither<E, B>

Added in v2.0.0 v2.0.0 中添加

model   模型

IOEither (interface)   IOEither(接口)

Signature 签名

export interface IOEither<E, A> extends IO<Either<E, A>> {}

Added in v2.0.0 v2.0.0 中添加

pattern matching   模式匹配

fold   折叠

Alias of matchE.  matchE 的别名。

Signature 签名

export declare const fold: <E, A, B>(
  onLeft: (e: E) => I.IO<B>,
  onRight: (a: A) => I.IO<B>
) => (ma: IOEither<E, A>) => I.IO<B>

Added in v2.0.0 v2.0.0 中添加

foldW   折叠W

Alias of matchEW.  matchEW 的别名。

Signature 签名

export declare const foldW: <E, B, A, C>(
  onLeft: (e: E) => I.IO<B>,
  onRight: (a: A) => I.IO<C>
) => (ma: IOEither<E, A>) => I.IO<B | C>

Added in v2.10.0 v2.10.0 中添加

match   匹配

Signature 签名

export declare const match: <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: IOEither<E, A>) => I.IO<B>

Added in v2.10.0 v2.10.0 中添加

matchE   匹配E

The E suffix (short for Effect) means that the handlers return an effect (IO).
E 后缀(Effect 的缩写)意味着处理程序返回一个效果 ( IO )。

Signature 签名

export declare const matchE: <E, A, B>(
  onLeft: (e: E) => I.IO<B>,
  onRight: (a: A) => I.IO<B>
) => (ma: IOEither<E, A>) => I.IO<B>

Added in v2.10.0 v2.10.0 中添加

matchEW   匹配电子战

Less strict version of matchE.
matchE 的不太严格版本。

The W suffix (short for Widening) means that the handler return types will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const matchEW: <E, B, A, C>(
  onLeft: (e: E) => I.IO<B>,
  onRight: (a: A) => I.IO<C>
) => (ma: IOEither<E, A>) => I.IO<B | C>

Added in v2.10.0 v2.10.0 中添加

matchW   匹配W

Less strict version of match.
match 的不太严格版本。

The W suffix (short for Widening) means that the handler return types will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const matchW: <E, B, A, C>(
  onLeft: (e: E) => B,
  onRight: (a: A) => C
) => (ma: IOEither<E, A>) => I.IO<B | C>

Added in v2.10.0 v2.10.0 中添加

sequencing   测序

flatMap   平面地图

Signature 签名

export declare const flatMap: {
  <A, E2, B>(f: (a: A) => IOEither<E2, B>): <E1>(ma: IOEither<E1, A>) => IOEither<E2 | E1, B>
  <E1, A, E2, B>(ma: IOEither<E1, A>, f: (a: A) => IOEither<E2, B>): IOEither<E1 | E2, B>
}

Added in v2.14.0 v2.14.0 中添加

flatMapEither   平面地图要么

Signature 签名

export declare const flatMapEither: {
  <A, E2, B>(f: (a: A) => E.Either<E2, B>): <E1>(self: IOEither<E1, A>) => IOEither<E2 | E1, B>
  <E1, A, E2, B>(self: IOEither<E1, A>, f: (a: A) => E.Either<E2, B>): IOEither<E1 | E2, B>
}

Added in v2.15.0 v2.15.0 中添加

flatMapIO   平面MapIO

Signature 签名

export declare const flatMapIO: {
  <A, B>(f: (a: A) => I.IO<B>): <E>(self: IOEither<E, A>) => IOEither<E, B>
  <E, A, B>(self: IOEither<E, A>, f: (a: A) => I.IO<B>): IOEither<E, B>
}

Added in v2.16.0 v2.16.0 中添加

flatMapNullable   平面地图可空

Signature 签名

export declare const flatMapNullable: {
  <A, B, E2>(f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): <E1>(
    self: IOEither<E1, A>
  ) => IOEither<E2 | E1, NonNullable<B>>
  <E1, A, B, E2>(self: IOEither<E1, A>, f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): IOEither<
    E1 | E2,
    NonNullable<B>
  >
}

Added in v2.15.0 v2.15.0 中添加

flatMapOption   平面地图选项

Signature 签名

export declare const flatMapOption: {
  <A, B, E2>(f: (a: A) => Option<B>, onNone: (a: A) => E2): <E1>(self: IOEither<E1, A>) => IOEither<E2 | E1, B>
  <E1, A, B, E2>(self: IOEither<E1, A>, f: (a: A) => Option<B>, onNone: (a: A) => E2): IOEither<E1 | E2, B>
}

Added in v2.15.0 v2.15.0 中添加

flatten   压扁

Signature 签名

export declare const flatten: <E, A>(mma: IOEither<E, IOEither<E, A>>) => IOEither<E, A>

Added in v2.0.0 v2.0.0 中添加

flattenW   展平W

Less strict version of flatten.
flatten 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const flattenW: <E1, E2, A>(mma: IOEither<E1, IOEither<E2, A>>) => IOEither<E1 | E2, A>

Added in v2.11.0 v2.11.0 中添加

traversing   穿越

sequenceArray   序列数组

Equivalent to ReadonlyArray#sequence(Applicative). 相当于 ReadonlyArray#sequence(Applicative)

Signature 签名

export declare const sequenceArray: <E, A>(arr: readonly IOEither<E, A>[]) => IOEither<E, readonly A[]>

Added in v2.9.0 v2.9.0中添加

sequenceSeqArray   序列SeqArray

Equivalent to ReadonlyArray#sequence(ApplicativeSeq). 相当于 ReadonlyArray#sequence(ApplicativeSeq)

Signature 签名

export declare const sequenceSeqArray: <E, A>(arr: readonly IOEither<E, A>[]) => IOEither<E, readonly A[]>

Added in v2.9.0 v2.9.0中添加

traverseArray   遍历数组

Equivalent to ReadonlyArray#traverse(Applicative). 相当于 ReadonlyArray#traverse(Applicative)

Signature 签名

export declare const traverseArray: <A, E, B>(
  f: (a: A) => IOEither<E, B>
) => (as: readonly A[]) => IOEither<E, readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseArrayWithIndex   带索引遍历数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseArrayWithIndex: <A, E, B>(
  f: (index: number, a: A) => IOEither<E, B>
) => (as: readonly A[]) => IOEither<E, readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseReadonlyArrayWithIndex
遍历带索引的只读数组

Equivalent to ReadonlyArray#traverseWithIndex(ApplicativePar). 相当于 ReadonlyArray#traverseWithIndex(ApplicativePar)

Signature 签名

export declare const traverseReadonlyArrayWithIndex: <A, E, B>(
  f: (index: number, a: A) => IOEither<E, B>
) => (as: readonly A[]) => IOEither<E, readonly B[]>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyArrayWithIndexSeq
遍历ReadonlyArrayWithIndexSeq

Equivalent to ReadonlyArray#traverseWithIndex(ApplicativeSeq). 相当于 ReadonlyArray#traverseWithIndex(ApplicativeSeq)

Signature 签名

export declare const traverseReadonlyArrayWithIndexSeq: <A, E, B>(
  f: (index: number, a: A) => IOEither<E, B>
) => (as: readonly A[]) => IOEither<E, readonly B[]>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyNonEmptyArrayWithIndex
遍历ReadonlyNonEmptyArrayWithIndex

Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar). 相当于 ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar)

Signature 签名

export declare const traverseReadonlyNonEmptyArrayWithIndex: <A, E, B>(
  f: (index: number, a: A) => IOEither<E, B>
) => (as: ReadonlyNonEmptyArray<A>) => IOEither<E, ReadonlyNonEmptyArray<B>>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyNonEmptyArrayWithIndexSeq
遍历ReadonlyNonEmptyArrayWithIndexSeq

Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq). 相当于 ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq)

Signature 签名

export declare const traverseReadonlyNonEmptyArrayWithIndexSeq: <A, E, B>(
  f: (index: number, a: A) => IOEither<E, B>
) => (as: ReadonlyNonEmptyArray<A>) => IOEither<E, ReadonlyNonEmptyArray<B>>

Added in v2.11.0 v2.11.0 中添加

traverseSeqArray   遍历SeqArray

Equivalent to ReadonlyArray#traverse(ApplicativeSeq). 相当于 ReadonlyArray#traverse(ApplicativeSeq)

Signature 签名

export declare const traverseSeqArray: <A, E, B>(
  f: (a: A) => IOEither<E, B>
) => (as: readonly A[]) => IOEither<E, readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseSeqArrayWithIndex
带索引的遍历SeqArray

Equivalent to ReadonlyArray#traverseWithIndex(ApplicativeSeq). 相当于 ReadonlyArray#traverseWithIndex(ApplicativeSeq)

Signature 签名

export declare const traverseSeqArrayWithIndex: <A, E, B>(
  f: (index: number, a: A) => IOEither<E, B>
) => (as: readonly A[]) => IOEither<E, readonly B[]>

Added in v2.9.0 v2.9.0中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'IOEither'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

ApT   易于

Signature 签名

export declare const ApT: IOEither<never, readonly []>

Added in v2.11.0 v2.11.0 中添加

ap   美联社

Signature 签名

export declare const ap: <E, A>(fa: IOEither<E, A>) => <B>(fab: IOEither<E, (a: A) => B>) => IOEither<E, B>

Added in v2.0.0 v2.0.0 中添加

apFirst   应用程序第一

Combine two effectful actions, keeping only the result of the first.
结合两个有效的操作,仅保留第一个操作的结果。

Signature 签名

export declare const apFirst: <E, B>(second: IOEither<E, B>) => <A>(first: IOEither<E, A>) => IOEither<E, A>

Added in v2.0.0 v2.0.0 中添加

apFirstW   apFirstW

Less strict version of apFirst.
apFirst 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const apFirstW: <E2, B>(
  second: IOEither<E2, B>
) => <E1, A>(first: IOEither<E1, A>) => IOEither<E2 | E1, A>

Added in v2.12.0 v2.12.0 中添加

apSecond   ap秒

Combine two effectful actions, keeping only the result of the second.
结合两个有效的操作,只保留第二个的结果。

Signature 签名

export declare const apSecond: <E, B>(second: IOEither<E, B>) => <A>(first: IOEither<E, A>) => IOEither<E, B>

Added in v2.0.0 v2.0.0 中添加

apSecondW   apSecondW

Less strict version of apSecond.
apSecond 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const apSecondW: <E2, B>(
  second: IOEither<E2, B>
) => <E1, A>(first: IOEither<E1, A>) => IOEither<E2 | E1, B>

Added in v2.12.0 v2.12.0 中添加

apW   平均功率

Less strict version of ap.
ap 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const apW: <E2, A>(
  fa: IOEither<E2, A>
) => <E1, B>(fab: IOEither<E1, (a: A) => B>) => IOEither<E2 | E1, B>

Added in v2.8.0 v2.8.0 中添加

bracket   括号

Make sure that a resource is cleaned up in the event of an exception (*). The release action is called regardless of whether the body action throws (*) or returns.
确保在发生异常时清理资源 (*)。无论主体操作是抛出 (*) 还是返回,都会调用释放操作。

(*) i.e. returns a Left
(*) 即返回 Left

Signature 签名

export declare const bracket: <E, A, B>(
  acquire: IOEither<E, A>,
  use: (a: A) => IOEither<E, B>,
  release: (a: A, e: E.Either<E, B>) => IOEither<E, void>
) => IOEither<E, B>

Added in v2.0.0 v2.0.0 中添加

bracketW   支架W

Less strict version of bracket.
bracket 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const bracketW: <E1, A, E2, B, E3>(
  acquire: IOEither<E1, A>,
  use: (a: A) => IOEither<E2, B>,
  release: (a: A, e: E.Either<E2, B>) => IOEither<E3, void>
) => IOEither<E1 | E2 | E3, B>

Added in v2.12.0 v2.12.0 中添加

swap   交换

Signature 签名

export declare const swap: <E, A>(ma: IOEither<E, A>) => IOEither<A, E>

Added in v2.0.0 v2.0.0 中添加

throwError   抛出错误

Signature 签名

export declare const throwError: <E, A>(e: E) => IOEither<E, A>

Added in v2.7.0 v2.7.0 中添加

zone of death
死亡地带

Applicative 适用性

Use ApplicativePar instead 使用 ApplicativePar 代替

Signature 签名

export declare const Applicative: Applicative2<'IOEither'>

Added in v2.7.0 v2.7.0 中添加

getApplyMonoid 获取应用Monoid

Use getApplicativeMonoid instead. 请改用 getApplicativeMonoid

Signature 签名

export declare const getApplyMonoid: <E, A>(M: Monoid<A>) => Monoid<IOEither<E, A>>

Added in v2.0.0 v2.0.0 中添加

getApplySemigroup 获取ApplySemigroup

Use getApplySemigroup instead. 请改用 getApplySemigroup

Signature 签名

export declare const getApplySemigroup: <E, A>(S: Semigroup<A>) => Semigroup<IOEither<E, A>>

Added in v2.0.0 v2.0.0 中添加

getIOValidation 获取IO验证

Use getApplicativeIOValidation and getAltIOValidation. 使用 getApplicativeIOValidationgetAltIOValidation

Signature 签名

export declare function getIOValidation<E>(
  SE: Semigroup<E>
): Monad2C<URI, E> & Bifunctor2<URI> & Alt2C<URI, E> & MonadIO2C<URI, E> & MonadThrow2C<URI, E>

Added in v2.0.0 v2.0.0 中添加

getSemigroup 获取半群

Use getApplySemigroup instead. 请改用 getApplySemigroup

Signature 签名

export declare const getSemigroup: <E, A>(S: Semigroup<A>) => Semigroup<IOEither<E, A>>

Added in v2.0.0 v2.0.0 中添加

ioEither io要么

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass IOE.Functor instead of IOE.ioEither (where IOE is from import IOE from 'fp-ts/IOEither')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 IOE.Functor 而不是 IOE.ioEither (其中 IOE 来自 import IOE from 'fp-ts/IOEither'

Signature 签名

export declare const ioEither: Monad2<'IOEither'> &
  Bifunctor2<'IOEither'> &
  Alt2<'IOEither'> &
  MonadIO2<'IOEither'> &
  MonadThrow2<'IOEither'>

Added in v2.0.0 v2.0.0 中添加

IOOption overview  IO选项概述

IOOption<A> represents a synchronous computation that either yields a value of type A or nothing.
IOOption<A> 表示同步计算,要么产生 A 类型的值,要么不产生任何结果。

If you want to represent a synchronous computation that never fails, please see IO. If you want to represent a synchronous computation that may fail, please see IOEither.
如果你想表示永不失败的同步计算,请参阅 IO 。如果你想表示一个可能失败的同步计算,请参见 IOEither

Added in v2.12.0 v2.12.0 中添加


Table of contents
目录


combinators   组合器

tap   轻敲

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tap: {
  <A, _>(self: IOOption<A>, f: (a: A) => IOOption<_>): IOOption<A>
  <A, _>(f: (a: A) => IOOption<_>): (self: IOOption<A>) => IOOption<A>
}

Added in v2.15.0 v2.15.0 中添加

tapEither   点击任一

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapEither: {
  <A, E, _>(f: (a: A) => Either<E, _>): (self: IOOption<A>) => IOOption<A>
  <A, E, _>(self: IOOption<A>, f: (a: A) => Either<E, _>): IOOption<A>
}

Example 例子

import { pipe } from 'fp-ts/function'
import * as IOO from 'fp-ts/IOOption'
import * as O from 'fp-ts/Option'
import * as E from 'fp-ts/Either'

const compute = (value: number) =>
  pipe(
    IOO.of(value),
    IOO.tapEither((value) => (value > 0 ? E.right('ok') : E.left('error')))
  )

assert.deepStrictEqual(compute(1)(), O.of(1))
assert.deepStrictEqual(compute(-1)(), O.none)

Added in v2.16.0 v2.16.0 中添加

tapIO   tapIO

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapIO: {
  <A, _>(f: (a: A) => I.IO<_>): (self: IOOption<A>) => IOOption<A>
  <A, _>(self: IOOption<A>, f: (a: A) => I.IO<_>): IOOption<A>
}

Example 例子

import { pipe } from 'fp-ts/function'
import * as IOO from 'fp-ts/IOOption'
import * as O from 'fp-ts/Option'
import * as Console from 'fp-ts/Console'

// Will produce `Hello, fp-ts` to the stdout
const effectA = pipe(
  IOO.of('fp-ts'),
  IOO.tapIO((value) => Console.log(`Hello, ${value}`))
)

// No output to the stdout
const effectB = pipe(
  IOO.none as IOO.IOOption<string>,
  IOO.tapIO((value) => Console.log(`Hello, ${value}`))
)

async function test() {
  assert.deepStrictEqual(effectA(), O.of('fp-ts'))
  assert.deepStrictEqual(effectB(), O.none)
}

test()

Added in v2.16.0 v2.16.0 中添加

constructors  构造函数

none   没有任何

Signature 签名

export declare const none: IOOption<never>

Added in v2.12.0 v2.12.0 中添加

of  

Signature 签名

export declare const of: <A>(a: A) => IOOption<A>

Added in v2.12.0 v2.12.0 中添加

some   一些

Signature 签名

export declare const some: <A>(a: A) => IOOption<A>

Added in v2.12.0 v2.12.0 中添加

conversions   转换

fromEither   来自任一

Signature 签名

export declare const fromEither: <A>(fa: Either<unknown, A>) => IOOption<A>

Added in v2.12.0 v2.12.0 中添加

fromIO   来自IO

Signature 签名

export declare const fromIO: <A>(fa: I.IO<A>) => IOOption<A>

Added in v2.12.0 v2.12.0 中添加

fromIOEither   来自IOEither

Signature 签名

export declare const fromIOEither: <A>(fa: IOEither<unknown, A>) => IOOption<A>

Added in v2.12.0 v2.12.0 中添加

fromNullable   来自可为空的

Signature 签名

export declare const fromNullable: <A>(a: A) => IOOption<NonNullable<A>>

Added in v2.12.0 v2.12.0 中添加

fromOption   来自选项

Signature 签名

export declare const fromOption: <A>(fa: O.Option<A>) => IOOption<A>

Added in v2.12.0 v2.12.0 中添加

toNullable   为可空

Signature 签名

export declare const toNullable: <A>(ma: IOOption<A>) => I.IO<A | null>

Added in v2.12.0 v2.12.0 中添加

toUndefined   未定义

Signature 签名

export declare const toUndefined: <A>(ma: IOOption<A>) => I.IO<A | undefined>

Added in v2.12.0 v2.12.0 中添加

do notation   做记号

Do  

Signature 签名

export declare const Do: IOOption<{}>

Added in v2.12.0 v2.12.0 中添加

apS   apS

Signature 签名

export declare const apS: <N, A, B>(
  name: Exclude<N, keyof A>,
  fb: IOOption<B>
) => (fa: IOOption<A>) => IOOption<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.12.0 v2.12.0 中添加

bind   绑定

Signature 签名

export declare const bind: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => IOOption<B>
) => (ma: IOOption<A>) => IOOption<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.12.0 v2.12.0 中添加

bindTo   绑定到

Signature 签名

export declare const bindTo: <N>(name: N) => <A>(fa: IOOption<A>) => IOOption<{ readonly [K in N]: A }>

Added in v2.12.0 v2.12.0 中添加

guard   警卫

Signature 签名

export declare const guard: (b: boolean) => IOOption<void>

Added in v2.12.0 v2.12.0 中添加

let  

Signature 签名

export declare const let: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => (fa: IOOption<A>) => IOOption<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.13.0 v2.13.0 中添加

error handling   错误处理

alt   替代

Signature 签名

export declare const alt: <A>(second: LazyArg<IOOption<A>>) => (first: IOOption<A>) => IOOption<A>

Added in v2.12.0 v2.12.0 中添加

altW   替代W

Less strict version of alt.
alt 的不太严格版本。

The W suffix (short for Widening) means that the return types will be merged.
W 后缀(Widening 的缩写)意味着返回类型将被合并。

Signature 签名

export declare const altW: <B>(second: LazyArg<IOOption<B>>) => <A>(first: IOOption<A>) => IOOption<B | A>

Added in v2.12.0 v2.12.0 中添加

getOrElse  获取或否则

Signature 签名

export declare const getOrElse: <A>(onNone: LazyArg<I.IO<A>>) => (fa: IOOption<A>) => I.IO<A>

Added in v2.12.0 v2.12.0 中添加

getOrElseW   获取或否则W

Less strict version of getOrElse.
getOrElse 的不太严格版本。

The W suffix (short for Widening) means that the handler return type will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const getOrElseW: <B>(onNone: LazyArg<I.IO<B>>) => <A>(ma: IOOption<A>) => I.IO<B | A>

Added in v2.12.0 v2.12.0 中添加

filtering   过滤

compact   袖珍的

Signature 签名

export declare const compact: <A>(fa: IOOption<O.Option<A>>) => IOOption<A>

Added in v2.12.0 v2.12.0 中添加

filter   筛选

Signature 签名

export declare const filter: {
  <A, B extends A>(refinement: Refinement<A, B>): (fb: IOOption<A>) => IOOption<B>
  <A>(predicate: Predicate<A>): <B extends A>(fb: IOOption<B>) => IOOption<B>
  <A>(predicate: Predicate<A>): (fa: IOOption<A>) => IOOption<A>
}

Added in v2.12.0 v2.12.0 中添加

filterMap   过滤映射

Signature 签名

export declare const filterMap: <A, B>(f: (a: A) => O.Option<B>) => (fga: IOOption<A>) => IOOption<B>

Added in v2.12.0 v2.12.0 中添加

partition   分割

Signature 签名

export declare const partition: {
  <A, B extends A>(refinement: Refinement<A, B>): (fb: IOOption<A>) => Separated<IOOption<A>, IOOption<B>>
  <A>(predicate: Predicate<A>): <B extends A>(fb: IOOption<B>) => Separated<IOOption<B>, IOOption<B>>
  <A>(predicate: Predicate<A>): (fa: IOOption<A>) => Separated<IOOption<A>, IOOption<A>>
}

Added in v2.12.0 v2.12.0 中添加

partitionMap   分区图

Signature 签名

export declare const partitionMap: <A, B, C>(
  f: (a: A) => Either<B, C>
) => (fa: IOOption<A>) => Separated<IOOption<B>, IOOption<C>>

Added in v2.12.0 v2.12.0 中添加

separate   分离

Signature 签名

export declare const separate: <A, B>(fa: IOOption<Either<A, B>>) => Separated<IOOption<A>, IOOption<B>>

Added in v2.12.0 v2.12.0 中添加

instances   实例

Alt   替代

Signature 签名

export declare const Alt: Alt1<'IOOption'>

Added in v2.12.0 v2.12.0 中添加

Alternative   选择

Signature 签名

export declare const Alternative: Alternative1<'IOOption'>

Added in v2.12.0 v2.12.0 中添加

Applicative   适用性

Signature 签名

export declare const Applicative: Applicative1<'IOOption'>

Added in v2.12.0 v2.12.0 中添加

Apply   申请

Signature 签名

export declare const Apply: Apply1<'IOOption'>

Added in v2.12.0 v2.12.0 中添加

Chain  

Signature 签名

export declare const Chain: chainable.Chain1<'IOOption'>

Added in v2.12.0 v2.12.0 中添加

Compactable   紧凑型

Signature 签名

export declare const Compactable: Compactable1<'IOOption'>

Added in v2.12.0 v2.12.0 中添加

Filterable   可过滤

Signature 签名

export declare const Filterable: Filterable1<'IOOption'>

Added in v2.12.0 v2.12.0 中添加

FromEither   来自任一

Signature 签名

export declare const FromEither: FromEither1<'IOOption'>

Added in v2.12.0 v2.12.0 中添加

FromIO   来自IO

Signature 签名

export declare const FromIO: FromIO1<'IOOption'>

Added in v2.12.0 v2.12.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor1<'IOOption'>

Added in v2.12.0 v2.12.0 中添加

Monad   单子

Signature 签名

export declare const Monad: Monad1<'IOOption'>

Added in v2.12.0 v2.12.0 中添加

MonadIO   莫纳德奥

Signature 签名

export declare const MonadIO: MonadIO1<'IOOption'>

Added in v2.12.0 v2.12.0 中添加

Pointed  

Signature 签名

export declare const Pointed: Pointed1<'IOOption'>

Added in v2.12.0 v2.12.0 中添加

Zero  

Signature 签名

export declare const Zero: Zero1<'IOOption'>

Added in v2.12.0 v2.12.0 中添加

legacy   遗产

chain  

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chain: <A, B>(f: (a: A) => IOOption<B>) => (ma: IOOption<A>) => IOOption<B>

Added in v2.12.0 v2.12.0 中添加

chainEitherK  链EiK

Alias of flatMapEither.  flatMapEither 的别名。

Signature 签名

export declare const chainEitherK: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: IOOption<A>) => IOOption<B>

Added in v2.12.0 v2.12.0 中添加

chainFirst   链优先

Alias of tap.  tap 的别名。

Signature 签名

export declare const chainFirst: <A, B>(f: (a: A) => IOOption<B>) => (first: IOOption<A>) => IOOption<A>

Added in v2.12.0 v2.12.0 中添加

chainFirstEitherK  链FirstEiK

Alias of tapEither.  tapEither 的别名。

Signature 签名

export declare const chainFirstEitherK: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: IOOption<A>) => IOOption<A>

Added in v2.12.0 v2.12.0 中添加

chainFirstIOK  链第一IOK

Alias of tapIO.  tapIO 的别名。

Signature 签名

export declare const chainFirstIOK: <A, B>(f: (a: A) => I.IO<B>) => (first: IOOption<A>) => IOOption<A>

Added in v2.12.0 v2.12.0 中添加

chainIOK  链IOK

Alias of flatMapIO.  flatMapIO 的别名。

Signature 签名

export declare const chainIOK: <A, B>(f: (a: A) => I.IO<B>) => (first: IOOption<A>) => IOOption<B>

Added in v2.12.0 v2.12.0 中添加

chainNullableK   链可空K

Alias of flatMapNullable.  flatMapNullable 的别名。

Signature 签名

export declare const chainNullableK: <A, B>(
  f: (a: A) => B | null | undefined
) => (ma: IOOption<A>) => IOOption<NonNullable<B>>

Added in v2.12.0 v2.12.0 中添加

chainOptionK   链选项K

Alias of flatMapOption.  flatMapOption 的别名。

Signature 签名

export declare const chainOptionK: <A, B>(f: (a: A) => O.Option<B>) => (ma: IOOption<A>) => IOOption<B>

Added in v2.12.0 v2.12.0 中添加

lifting   起重

fromEitherK   来自EitherK

Signature 签名

export declare const fromEitherK: <E, A extends readonly unknown[], B>(
  f: (...a: A) => Either<E, B>
) => (...a: A) => IOOption<B>

Added in v2.12.0 v2.12.0 中添加

fromIOK   来自IOK

Signature 签名

export declare const fromIOK: <A extends readonly unknown[], B>(f: (...a: A) => I.IO<B>) => (...a: A) => IOOption<B>

Added in v2.12.0 v2.12.0 中添加

fromNullableK  来自可空K

Signature 签名

export declare const fromNullableK: <A extends readonly unknown[], B>(
  f: (...a: A) => B | null | undefined
) => (...a: A) => IOOption<NonNullable<B>>

Added in v2.12.0 v2.12.0 中添加

fromOptionK   来自选项K

Signature 签名

export declare const fromOptionK: <A extends readonly unknown[], B>(
  f: (...a: A) => O.Option<B>
) => (...a: A) => IOOption<B>

Added in v2.12.0 v2.12.0 中添加

fromPredicate   来自谓词

Signature 签名

export declare const fromPredicate: {
  <A, B extends A>(refinement: Refinement<A, B>): (a: A) => IOOption<B>
  <A>(predicate: Predicate<A>): <B extends A>(b: B) => IOOption<B>
  <A>(predicate: Predicate<A>): (a: A) => IOOption<A>
}

Added in v2.12.0 v2.12.0 中添加

mapping   映射

as   作为

Maps the Some value of this IOOption to the specified constant value.
将此 IOOptionSome 值映射到指定的常量值。

Signature 签名

export declare const as: {
  <A>(a: A): <_>(self: IOOption<_>) => IOOption<A>
  <_, A>(self: IOOption<_>, a: A): IOOption<A>
}

Added in v2.16.0 v2.16.0 中添加

asUnit   作为单位

Maps the Some value of this IOOption to the void constant value.
将此 IOOptionSome 值映射到void 常量值。

Signature 签名

export declare const asUnit: <_>(self: IOOption<_>) => IOOption<void>

Added in v2.16.0 v2.16.0 中添加

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <B>(fab: IOOption<(a: A) => B>) => IOOption<B>

Added in v2.12.0 v2.12.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => (fa: IOOption<A>) => IOOption<B>

Added in v2.12.0 v2.12.0 中添加

model   模型

IOOption (interface)   IOOption(接口)

Signature 签名

export interface IOOption<A> extends IO<Option<A>> {}

Added in v2.12.0 v2.12.0 中添加

pattern matching   模式匹配

fold   折叠

Alias of matchE.  matchE 的别名。

Signature 签名

export declare const fold: <B, A>(onNone: () => I.IO<B>, onSome: (a: A) => I.IO<B>) => (ma: IOOption<A>) => I.IO<B>

Added in v2.12.0 v2.12.0 中添加

match   匹配

Signature 签名

export declare const match: <B, A>(onNone: () => B, onSome: (a: A) => B) => (ma: IOOption<A>) => I.IO<B>

Added in v2.12.0 v2.12.0 中添加

matchE   匹配E

The E suffix (short for Effect) means that the handlers return an effect (IO).
E 后缀(Effect 的缩写)意味着处理程序返回一个效果 ( IO )。

Signature 签名

export declare const matchE: <B, A>(onNone: () => I.IO<B>, onSome: (a: A) => I.IO<B>) => (ma: IOOption<A>) => I.IO<B>

Added in v2.12.0 v2.12.0 中添加

matchEW   匹配电子战

Less strict version of matchE.
matchE 的不太严格版本。

The W suffix (short for Widening) means that the handler return types will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const matchEW: <B, C, A>(
  onNone: () => I.IO<B>,
  onSome: (a: A) => I.IO<C>
) => (ma: IOOption<A>) => I.IO<B | C>

Added in v2.12.0 v2.12.0 中添加

matchW   匹配W

Less strict version of match.
match 的不太严格版本。

The W suffix (short for Widening) means that the handler return types will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const matchW: <B, A, C>(onNone: () => B, onSome: (a: A) => C) => (ma: IOOption<A>) => I.IO<B | C>

Added in v2.12.0 v2.12.0 中添加

sequencing   测序

flatMap   平面地图

Signature 签名

export declare const flatMap: {
  <A, B>(f: (a: A) => IOOption<B>): (ma: IOOption<A>) => IOOption<B>
  <A, B>(ma: IOOption<A>, f: (a: A) => IOOption<B>): IOOption<B>
}

Added in v2.14.0 v2.14.0 中添加

flatMapEither   平面地图要么

Signature 签名

export declare const flatMapEither: {
  <A, B, _>(f: (a: A) => Either<_, B>): (self: IOOption<A>) => IOOption<B>
  <A, B, _>(self: IOOption<A>, f: (a: A) => Either<_, B>): IOOption<B>
}

Added in v2.16.0 v2.16.0 中添加

flatMapIO   平面MapIO

Signature 签名

export declare const flatMapIO: {
  <A, B>(f: (a: A) => I.IO<B>): (self: IOOption<A>) => IOOption<B>
  <A, B>(self: IOOption<A>, f: (a: A) => I.IO<B>): IOOption<B>
}

Added in v2.16.0 v2.16.0 中添加

flatMapNullable   平面地图可空

Signature 签名

export declare const flatMapNullable: {
  <A, B>(f: (a: A) => B | null | undefined): (self: IOOption<A>) => IOOption<B>
  <A, B>(self: IOOption<A>, f: (a: A) => B | null | undefined): IOOption<B>
}

Added in v2.16.0 v2.16.0 中添加

flatMapOption   平面地图选项

Signature 签名

export declare const flatMapOption: {
  <A, B>(f: (a: A) => O.Option<B>): (self: IOOption<A>) => IOOption<B>
  <A, B>(self: IOOption<A>, f: (a: A) => O.Option<B>): IOOption<B>
}

Added in v2.16.0 v2.16.0 中添加

flatten   压扁

Signature 签名

export declare const flatten: <A>(mma: IOOption<IOOption<A>>) => IOOption<A>

Added in v2.12.0 v2.12.0 中添加

traversing   穿越

traverseReadonlyArrayWithIndex
遍历带索引的只读数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseReadonlyArrayWithIndex: <A, B>(
  f: (index: number, a: A) => IOOption<B>
) => (as: readonly A[]) => IOOption<readonly B[]>

Added in v2.12.0 v2.12.0 中添加

traverseReadonlyNonEmptyArrayWithIndex
遍历ReadonlyNonEmptyArrayWithIndex

Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(Applicative). 相当于 ReadonlyNonEmptyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseReadonlyNonEmptyArrayWithIndex: <A, B>(
  f: (index: number, a: A) => IOOption<B>
) => (as: ReadonlyNonEmptyArray<A>) => IOOption<ReadonlyNonEmptyArray<B>>

Added in v2.12.0 v2.12.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'IOOption'

Added in v2.12.0 v2.12.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.12.0 v2.12.0 中添加

utils   实用程序

ApT   易于

Signature 签名

export declare const ApT: IOOption<readonly []>

Added in v2.12.0 v2.12.0 中添加

ap   美联社

Signature 签名

export declare const ap: <A>(fa: IOOption<A>) => <B>(fab: IOOption<(a: A) => B>) => IOOption<B>

Added in v2.12.0 v2.12.0 中添加

apFirst   应用程序第一

Combine two effectful actions, keeping only the result of the first.
结合两个有效的操作,仅保留第一个操作的结果。

Signature 签名

export declare const apFirst: <B>(second: IOOption<B>) => <A>(first: IOOption<A>) => IOOption<A>

Added in v2.12.0 v2.12.0 中添加

apSecond   ap秒

Combine two effectful actions, keeping only the result of the second.
结合两个有效的操作,只保留第二个的结果。

Signature 签名

export declare const apSecond: <B>(second: IOOption<B>) => <A>(first: IOOption<A>) => IOOption<B>

Added in v2.12.0 v2.12.0 中添加

zero  

Signature 签名

export declare const zero: <A>() => IOOption<A>

Added in v2.12.0 v2.12.0 中添加

IORef overview  IORef 概述

Mutable references in the IO monad
IO monad 中的可变引用

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


constructors  构造函数

newIORef   新IORef

Signature 签名

export declare function newIORef<A>(a: A): IO<IORef<A>>

Added in v2.0.0 v2.0.0 中添加

model   模型

IORef (class)   IORef(类)

Signature 签名

export declare class IORef<A> {
  constructor(private value: A)
}

Example 例子

import { flatMap } from 'fp-ts/IO'
import { newIORef } from 'fp-ts/IORef'

assert.strictEqual(flatMap(newIORef(1), (ref) => flatMap(ref.write(2), () => ref.read))(), 2)

Added in v2.0.0 v2.0.0 中添加

write (method)   写(方法)

Signature 签名

write(a: A): IO<void>

Added in v2.0.0 v2.0.0 中添加

modify (method)   修改(方法)

Signature 签名

modify(f: (a: A) => A): IO<void>

Added in v2.0.0 v2.0.0 中添加

read (property)   读(属性)

Signature 签名

readonly read: IO<A>

Added in v2.0.0 v2.0.0 中添加

JoinSemilattice overview
JoinSemilattice概述

A join-semilattice (or upper semilattice) is a semilattice whose operation is called join, and which can be thought of as a least upper bound.
连接半格(或上半格)是其操作称为 join 的半格,可以将其视为最小上界。

A JoinSemilattice must satisfy the following laws:
JoinSemilattice 必须满足以下定律:

  • Associativity: a ∨ (b ∨ c) <-> (a ∨ b) ∨ c 关联性: a ∨ (b ∨ c) <-> (a ∨ b) ∨ c
  • Commutativity: a ∨ b <-> b ∨ a 交换性: a ∨ b <-> b ∨ a
  • Idempotency: a ∨ a <-> a 幂等性: a ∨ a <-> a

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

JoinSemilattice (interface)
JoinSemilattice(接口)

Signature 签名

export interface JoinSemilattice<A> {
  readonly join: (x: A, y: A) => A
}

Added in v2.0.0 v2.0.0 中添加

Json overview  Json概述

Added in v2.10.0 v2.10.0 中添加


Table of contents
目录


utils   实用程序

Json (type alias)
Json(类型别名)

Signature 签名

export type Json = boolean | number | string | null | JsonArray | JsonRecord

Added in v2.10.0 v2.10.0 中添加

JsonArray (interface)   JsonArray(接口)

Signature 签名

export interface JsonArray extends ReadonlyArray<Json> {}

Added in v2.10.0 v2.10.0 中添加

JsonRecord (interface)   JsonRecord(接口)

Signature 签名

export interface JsonRecord {
  readonly [key: string]: Json
}

Added in v2.10.0 v2.10.0 中添加

parse   解析

Converts a JavaScript Object Notation (JSON) string into a Json type.
将 JavaScript 对象表示法 (JSON) 字符串转换为 Json 类型。

Signature 签名

export declare const parse: (s: string) => Either<unknown, Json>

Example 例子

import * as J from 'fp-ts/Json'
import * as E from 'fp-ts/Either'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe('{"a":1}', J.parse), E.right({ a: 1 }))
assert.deepStrictEqual(pipe('{"a":}', J.parse), E.left(new SyntaxError('Unexpected token } in JSON at position 5')))

Added in v2.10.0 v2.10.0 中添加

stringify   字符串化

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
将 JavaScript 值转换为 JavaScript 对象表示法 (JSON) 字符串。

Signature 签名

export declare const stringify: <A>(a: A) => Either<unknown, string>

Example 例子

import * as E from 'fp-ts/Either'
import * as J from 'fp-ts/Json'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(J.stringify({ a: 1 }), E.right('{"a":1}'))
const circular: any = { ref: null }
circular.ref = circular
assert.deepStrictEqual(
  pipe(
    J.stringify(circular),
    E.mapLeft((e) => e instanceof Error && e.message.includes('Converting circular structure to JSON'))
  ),
  E.left(true)
)

Added in v2.10.0 v2.10.0 中添加

Lattice overview  格子概述

A Lattice must satisfy the following in addition to JoinSemilattice and MeetSemilattice laws:
除了 JoinSemilatticeMeetSemilattice 定律之外, Lattice 还必须满足以下条件:

  • Absorbtion law for meet: a ∧ (a ∨ b) <-> a
    满足吸收定律: a ∧ (a ∨ b) <-> a
  • Absorbtion law for join: a ∨ (a ∧ b) <-> a
    连接吸收定律: a ∨ (a ∧ b) <-> a

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Lattice (interface)   晶格(界面)

Signature 签名

export interface Lattice<A> extends JoinSemilattice<A>, MeetSemilattice<A> {}

Added in v2.0.0 v2.0.0 中添加

Magma overview  岩浆概述

A Magma is a pair (A, concat) in which A is a non-empty set and concat is a binary operation on A
Magma 是一对 (A, concat) ,其中 A 是非空集合, concat 是对 A 的二元运算

See Semigroup for some instances.
有关某些实例,请参阅半群。

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Magma (interface)   岩浆(界面)

Signature 签名

export interface Magma<A> {
  readonly concat: (x: A, y: A) => A
}

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

concatAll   全部连接

Given a sequence of as, concat them and return the total.
给定一个 as 序列,将它们连接起来并返回总数。

If as is empty, return the provided startWith value.
如果 as 为空,则返回提供的 startWith 值。

Signature 签名

export declare const concatAll: <A>(M: Magma<A>) => (startWith: A) => (as: readonly A[]) => A

Example 例子

import { concatAll } from 'fp-ts/Magma'
import * as N from 'fp-ts/number'

const subAll = concatAll(N.MagmaSub)(0)

assert.deepStrictEqual(subAll([1, 2, 3]), -6)

Added in v2.11.0 v2.11.0 中添加

endo   内切

Signature 签名

export declare const endo: <A>(f: Endomorphism<A>) => (M: Magma<A>) => Magma<A>

Added in v2.11.0 v2.11.0 中添加

filterFirst   过滤优先

Signature 签名

export declare const filterFirst: <A>(predicate: Predicate<A>) => (M: Magma<A>) => Magma<A>

Added in v2.11.0 v2.11.0 中添加

filterSecond   过滤器第二

Signature 签名

export declare const filterSecond: <A>(predicate: Predicate<A>) => (M: Magma<A>) => Magma<A>

Added in v2.11.0 v2.11.0 中添加

reverse   撤销

The dual of a Magma, obtained by swapping the arguments of concat.
Magma 的对偶,通过交换 concat 的参数获得。

Signature 签名

export declare const reverse: <A>(M: Magma<A>) => Magma<A>

Example 例子

import { reverse, concatAll } from 'fp-ts/Magma'
import * as N from 'fp-ts/number'

const subAll = concatAll(reverse(N.MagmaSub))(0)

assert.deepStrictEqual(subAll([1, 2, 3]), 2)

Added in v2.11.0 v2.11.0 中添加

Map overview   地图概览

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


constructors  构造函数

fromFoldable   来自可折叠

Create a map from a foldable collection of key/value pairs, using the specified Magma to combine values for duplicate keys.
从可折叠的键/值对集合创建映射,使用指定的 Magma 来组合重复键的值。

Signature 签名

export declare function fromFoldable<F extends URIS3, K, A>(
  E: Eq<K>,
  M: Magma<A>,
  F: Foldable3<F>
): <R, E>(fka: Kind3<F, R, E, [K, A]>) => Map<K, A>
export declare function fromFoldable<F extends URIS2, K, A>(
  E: Eq<K>,
  M: Magma<A>,
  F: Foldable2<F>
): <E>(fka: Kind2<F, E, [K, A]>) => Map<K, A>
export declare function fromFoldable<F extends URIS, K, A>(
  E: Eq<K>,
  M: Magma<A>,
  F: Foldable1<F>
): (fka: Kind<F, [K, A]>) => Map<K, A>
export declare function fromFoldable<F, K, A>(E: Eq<K>, M: Magma<A>, F: Foldable<F>): (fka: HKT<F, [K, A]>) => Map<K, A>

Added in v2.0.0 v2.0.0 中添加

filtering   过滤

compact   袖珍的

Signature 签名

export declare const compact: <K, A>(fa: Map<K, O.Option<A>>) => Map<K, A>

Added in v2.0.0 v2.0.0 中添加

filter   筛选

Signature 签名

export declare const filter: {
  <A, B extends A>(refinement: Refinement<A, B>): <K>(fa: Map<K, A>) => Map<K, B>
  <A>(predicate: Predicate<A>): <K, B extends A>(fb: Map<K, B>) => Map<K, B>
  <A>(predicate: Predicate<A>): <K>(fa: Map<K, A>) => Map<K, A>
}

Added in v2.0.0 v2.0.0 中添加

filterMap   过滤映射

Signature 签名

export declare const filterMap: <A, B>(f: (a: A) => O.Option<B>) => <K>(fa: Map<K, A>) => Map<K, B>

Added in v2.0.0 v2.0.0 中添加

getFilterableWithIndex   获取可过滤的索引

Signature 签名

export declare function getFilterableWithIndex<K = never>(): FilterableWithIndex2C<URI, K, K>

Added in v2.0.0 v2.0.0 中添加

getWitherable   变得枯萎

Signature 签名

export declare function getWitherable<K>(O: Ord<K>): Witherable2C<URI, K> & TraversableWithIndex2C<URI, K, K>

Added in v2.0.0 v2.0.0 中添加

partition   分割

Signature 签名

export declare const partition: {
  <A, B extends A>(refinement: Refinement<A, B>): <K>(fa: Map<K, A>) => Separated<Map<K, A>, Map<K, B>>
  <A>(predicate: Predicate<A>): <K, B extends A>(fb: Map<K, B>) => Separated<Map<K, B>, Map<K, B>>
  <A>(predicate: Predicate<A>): <K>(fa: Map<K, A>) => Separated<Map<K, A>, Map<K, A>>
}

Added in v2.0.0 v2.0.0 中添加

partitionMap   分区图

Signature 签名

export declare const partitionMap: <A, B, C>(
  f: (a: A) => Either<B, C>
) => <K>(fa: Map<K, A>) => Separated<Map<K, B>, Map<K, C>>

Added in v2.0.0 v2.0.0 中添加

separate   分离

Signature 签名

export declare const separate: <K, A, B>(fa: Map<K, Either<A, B>>) => Separated<Map<K, A>, Map<K, B>>

Added in v2.0.0 v2.0.0 中添加

folding   折叠式的

foldMap   折叠图

Signature 签名

export declare const foldMap: <K>(O: Ord<K>) => <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (m: Map<K, A>) => M

Added in v2.11.0 v2.11.0 中添加

foldMapWithIndex   带索引的折叠地图

Signature 签名

export declare const foldMapWithIndex: <K>(
  O: Ord<K>
) => <M>(M: Monoid<M>) => <A>(f: (k: K, a: A) => M) => (m: Map<K, A>) => M

Added in v2.11.0 v2.11.0 中添加

getFoldable   获取可折叠的

Signature 签名

export declare const getFoldable: <K>(O: Ord<K>) => Foldable2C<'Map', K>

Added in v2.11.0 v2.11.0 中添加

getFoldableWithIndex   获取FoldableWithIndex

Signature 签名

export declare const getFoldableWithIndex: <K>(O: Ord<K>) => FoldableWithIndex2C<'Map', K, K>

Added in v2.10.0 v2.10.0 中添加

reduce   减少

Signature 签名

export declare const reduce: <K>(O: Ord<K>) => <B, A>(b: B, f: (b: B, a: A) => B) => (m: Map<K, A>) => B

Added in v2.11.0 v2.11.0 中添加

reduceRight   减少右

Signature 签名

export declare const reduceRight: <K>(O: Ord<K>) => <B, A>(b: B, f: (a: A, b: B) => B) => (m: Map<K, A>) => B

Added in v2.11.0 v2.11.0 中添加

reduceRightWithIndex   减少右索引

Signature 签名

export declare const reduceRightWithIndex: <K>(
  O: Ord<K>
) => <B, A>(b: B, f: (k: K, a: A, b: B) => B) => (m: Map<K, A>) => B

Added in v2.11.0 v2.11.0 中添加

reduceWithIndex  减少索引

Signature 签名

export declare const reduceWithIndex: <K>(O: Ord<K>) => <B, A>(b: B, f: (k: K, b: B, a: A) => B) => (m: Map<K, A>) => B

Added in v2.11.0 v2.11.0 中添加

instances   实例

Compactable   紧凑型

Signature 签名

export declare const Compactable: Compactable2<'Map'>

Added in v2.7.0 v2.7.0 中添加

Filterable   可过滤

Signature 签名

export declare const Filterable: Filterable2<'Map'>

Added in v2.7.0 v2.7.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor2<'Map'>

Added in v2.7.0 v2.7.0 中添加

getDifferenceMagma   获取差异岩浆

Signature 签名

export declare const getDifferenceMagma: <K>(E: Eq<K>) => <A>() => Magma<Map<K, A>>

Added in v2.11.0 v2.11.0 中添加

getEq   得到方程

Signature 签名

export declare const getEq: <K, A>(SK: Eq<K>, SA: Eq<A>) => Eq<Map<K, A>>

Added in v2.0.0 v2.0.0 中添加

getIntersectionSemigroup
获取交集半群

Signature 签名

export declare const getIntersectionSemigroup: <K, A>(E: Eq<K>, S: Semigroup<A>) => Semigroup<Map<K, A>>

Added in v2.11.0 v2.11.0 中添加

getMonoid   获取Monoid

Gets Monoid instance for Maps given Semigroup instance for their values
获取 Maps 的 Monoid 实例,为其值指定 Semigroup 实例

Signature 签名

export declare function getMonoid<K, A>(SK: Eq<K>, SA: Semigroup<A>): Monoid<Map<K, A>>

Added in v2.0.0 v2.0.0 中添加

getShow   获取显示

Signature 签名

export declare const getShow: <K, A>(SK: Show<K>, SA: Show<A>) => Show<Map<K, A>>

Added in v2.0.0 v2.0.0 中添加

getUnionMonoid  获取UnionMonoid

Signature 签名

export declare const getUnionMonoid: <K, A>(E: Eq<K>, S: Semigroup<A>) => Monoid<Map<K, A>>

Added in v2.11.0 v2.11.0 中添加

getUnionSemigroup   获取UnionSemigroup

Signature 签名

export declare const getUnionSemigroup: <K, A>(E: Eq<K>, S: Semigroup<A>) => Semigroup<Map<K, A>>

Added in v2.11.0 v2.11.0 中添加

mapping   映射

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <E, B>(fab: Map<E, (a: A) => B>) => Map<E, B>

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => <K>(fa: Map<K, A>) => Map<K, B>

Added in v2.0.0 v2.0.0 中添加

mapWithIndex   带索引的映射

Signature 签名

export declare const mapWithIndex: <K, A, B>(f: (k: K, a: A) => B) => (fa: Map<K, A>) => Map<K, B>

Added in v2.7.1 v2.7.1 中添加

traversing   穿越

getTraversableWithIndex
getTraversableWithIndex

Signature 签名

export declare const getTraversableWithIndex: <K>(O: Ord<K>) => TraversableWithIndex2C<'Map', K, K>

Added in v2.10.0 v2.10.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'Map'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

collect   收集

Signature 签名

export declare function collect<K>(O: Ord<K>): <A, B>(f: (k: K, a: A) => B) => (m: Map<K, A>) => Array<B>

Added in v2.0.0 v2.0.0 中添加

deleteAt   删除处

Delete a key and value from a map
从映射中删除键和值

Signature 签名

export declare const deleteAt: <K>(E: Eq<K>) => (k: K) => <A>(m: Map<K, A>) => Map<K, A>

Added in v2.0.0 v2.0.0 中添加

difference   不同之处

Signature 签名

export declare const difference: <K>(E: Eq<K>) => <A>(_second: Map<K, A>) => (first: Map<K, A>) => Map<K, A>

Added in v2.11.0 v2.11.0 中添加

elem   埃莱姆

Test whether or not a value is a member of a map
测试某个值是否是映射的成员

Signature 签名

export declare const elem: <A>(E: Eq<A>) => { (a: A): <K>(m: Map<K, A>) => boolean; <K>(a: A, m: Map<K, A>): boolean }

Added in v2.0.0 v2.0.0 中添加

filterMapWithIndex   带索引的过滤映射

Signature 签名

export declare const filterMapWithIndex: <K, A, B>(f: (k: K, a: A) => O.Option<B>) => (fa: Map<K, A>) => Map<K, B>

Added in v2.10.0 v2.10.0 中添加

filterWithIndex   带索引的过滤器

Signature 签名

export declare function filterWithIndex<K, A, B extends A>(p: (k: K, a: A) => a is B): (m: Map<K, A>) => Map<K, B>
export declare function filterWithIndex<K, A>(p: (k: K, a: A) => boolean): <B extends A>(m: Map<K, B>) => Map<K, B>
export declare function filterWithIndex<K, A>(p: (k: K, a: A) => boolean): (m: Map<K, A>) => Map<K, A>

Added in v2.10.0 v2.10.0 中添加

intersection   路口

Signature 签名

export declare const intersection: <K, A>(
  E: Eq<K>,
  M: Magma<A>
) => (second: Map<K, A>) => (first: Map<K, A>) => Map<K, A>

Added in v2.11.0 v2.11.0 中添加

isEmpty   是空的

Test whether or not a map is empty
测试地图是否为空

Signature 签名

export declare const isEmpty: <K, A>(m: Map<K, A>) => boolean

Added in v2.0.0 v2.0.0 中添加

isSubmap   是子图

Test whether or not one Map contains all of the keys and values contained in another Map
测试一个 Map 是否包含另一个 Map 中包含的所有键和值

Signature 签名

export declare const isSubmap: <K, A>(
  SK: Eq<K>,
  SA: Eq<A>
) => { (that: Map<K, A>): (me: Map<K, A>) => boolean; (me: Map<K, A>, that: Map<K, A>): boolean }

Added in v2.0.0 v2.0.0 中添加

keys  

Get a sorted Array of the keys contained in a Map.
获取 Map 中包含的键的排序 Array

Signature 签名

export declare const keys: <K>(O: Ord<K>) => <A>(m: Map<K, A>) => K[]

Added in v2.0.0 v2.0.0 中添加

lookup   抬头

Lookup the value for a key in a Map.
Map 中查找键的值。

Signature 签名

export declare const lookup: <K>(E: Eq<K>) => {
  (k: K): <A>(m: Map<K, A>) => O.Option<A>
  <A>(k: K, m: Map<K, A>): O.Option<A>
}

Added in v2.0.0 v2.0.0 中添加

lookupWithKey   关键字查找

Lookup the value for a key in a Map. If the result is a Some, the existing key is also returned.
Map 中查找键的值。如果结果是 Some ,则还会返回现有的密钥。

Signature 签名

export declare function lookupWithKey<K>(E: Eq<K>): {
  (k: K): <A>(m: Map<K, A>) => Option<[K, A]>
  <A>(k: K, m: Map<K, A>): Option<[K, A]>
}

Added in v2.0.0 v2.0.0 中添加

member   成员

Test whether or not a key exists in a map
测试映射中是否存在某个键

Signature 签名

export declare const member: <K>(E: Eq<K>) => { (k: K): <A>(m: Map<K, A>) => boolean; <A>(k: K, m: Map<K, A>): boolean }

Added in v2.0.0 v2.0.0 中添加

modifyAt   修改处

Signature 签名

export declare const modifyAt: <K>(E: Eq<K>) => <A>(k: K, f: (a: A) => A) => (m: Map<K, A>) => O.Option<Map<K, A>>

Added in v2.0.0 v2.0.0 中添加

partitionMapWithIndex   带索引的分区映射

Signature 签名

export declare const partitionMapWithIndex: <K, A, B, C>(
  f: (k: K, a: A) => Either<B, C>
) => (fa: Map<K, A>) => Separated<Map<K, B>, Map<K, C>>

Added in v2.10.0 v2.10.0 中添加

partitionWithIndex   带索引分区

Signature 签名

export declare function partitionWithIndex<K, A, B extends A>(
  predicateWithIndex: (k: K, a: A) => a is B
): (fa: Map<K, A>) => Separated<Map<K, A>, Map<K, B>>
export declare function partitionWithIndex<K, A>(
  predicateWithIndex: (k: K, a: A) => boolean
): <B extends A>(fb: Map<K, B>) => Separated<Map<K, B>, Map<K, B>>
export declare function partitionWithIndex<K, A>(
  predicateWithIndex: (k: K, a: A) => boolean
): (fa: Map<K, A>) => Separated<Map<K, A>, Map<K, A>>

Added in v2.10.0 v2.10.0 中添加

pop   流行音乐

Delete a key and value from a map, returning the value as well as the subsequent map
从映射中删除键和值,返回该值以及后续映射

Signature 签名

export declare function pop<K>(E: Eq<K>): (k: K) => <A>(m: Map<K, A>) => Option<[A, Map<K, A>]>

Added in v2.0.0 v2.0.0 中添加

singleton   单例

Create a map with one key/value pair
使用一个键/值对创建一个映射

Signature 签名

export declare const singleton: <K, A>(k: K, a: A) => Map<K, A>

Added in v2.0.0 v2.0.0 中添加

size   尺寸

Calculate the number of key/value pairs in a map
计算映射中键/值对的数量

Signature 签名

export declare const size: <K, A>(m: Map<K, A>) => number

Added in v2.0.0 v2.0.0 中添加

toArray   到数组

Get a sorted Array of the key/value pairs contained in a Map.
获取 Map 中包含的键/值对的排序 Array

Signature 签名

export declare function toArray<K>(O: Ord<K>): <A>(m: Map<K, A>) => Array<[K, A]>

Added in v2.0.0 v2.0.0 中添加

toUnfoldable   至可展开

Unfolds a map into a list of key/value pairs
将映射展开为键/值对列表

Signature 签名

export declare function toUnfoldable<K, F extends URIS>(
  ord: Ord<K>,
  U: Unfoldable1<F>
): <A>(d: Map<K, A>) => Kind<F, [K, A]>
export declare function toUnfoldable<K, F>(ord: Ord<K>, U: Unfoldable<F>): <A>(d: Map<K, A>) => HKT<F, [K, A]>

Added in v2.0.0 v2.0.0 中添加

union   联盟

Signature 签名

export declare const union: <K, A>(E: Eq<K>, M: Magma<A>) => (second: Map<K, A>) => (first: Map<K, A>) => Map<K, A>

Added in v2.11.0 v2.11.0 中添加

updateAt   更新时间

Signature 签名

export declare const updateAt: <K>(E: Eq<K>) => <A>(k: K, a: A) => (m: Map<K, A>) => O.Option<Map<K, A>>

Added in v2.0.0 v2.0.0 中添加

upsertAt   更新插入

Insert or replace a key/value pair in a Map.
Map 中插入或替换键/值对。

Signature 签名

export declare const upsertAt: <K>(E: Eq<K>) => <A>(k: K, a: A) => (m: Map<K, A>) => Map<K, A>

Added in v2.0.0 v2.0.0 中添加

values   价值观

Get a sorted Array of the values contained in a Map.
获取 Map 中包含的值的排序 Array

Signature 签名

export declare const values: <A>(O: Ord<A>) => <K>(m: Map<K, A>) => A[]

Added in v2.0.0 v2.0.0 中添加

zone of death
死亡地带

empty 空的

Use a new Map() instead. 请改用 new Map()

Signature 签名

export declare const empty: Map<never, never>

Added in v2.0.0 v2.0.0 中添加

insertAt 插入位置

Use upsertAt instead. 请改用 upsertAt

Signature 签名

export declare const insertAt: <K>(E: Eq<K>) => <A>(k: K, a: A) => (m: Map<K, A>) => Map<K, A>

Added in v2.0.0 v2.0.0 中添加

map_ 地图_

Use Filterable instead. 请改用 Filterable

Signature 签名

export declare const map_: Filterable2<'Map'>

Added in v2.0.0 v2.0.0 中添加

MeetSemilattice overview
MeetSemilattice 概述

A meet-semilattice (or lower semilattice) is a semilattice whose operation is called meet, and which can be thought of as a greatest lower bound.
交半格(或下半格)是其操作称为 meet 的半格,可以将其视为最大下界。

A MeetSemilattice must satisfy the following laws:
MeetSemilattice 必须满足以下定律:

  • Associativity: a ∧ (b ∧ c) <-> (a ∧ b) ∧ c 关联性: a ∧ (b ∧ c) <-> (a ∧ b) ∧ c
  • Commutativity: a ∧ b <-> b ∧ a 交换性: a ∧ b <-> b ∧ a
  • Idempotency: a ∧ a <-> a 幂等性: a ∧ a <-> a

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

MeetSemilattice (interface)
MeetSemilattice(接口)

Signature 签名

export interface MeetSemilattice<A> {
  readonly meet: (x: A, y: A) => A
}

Added in v2.0.0 v2.0.0 中添加

Monad overview  单子概述

The Monad type class combines the operations of the Chain and Applicative type classes. Therefore, Monad instances represent type constructors which support sequential composition, and also lifting of functions of arbitrary arity.
Monad 类型类结合了 ChainApplicative 类型类的操作。因此, Monad 实例表示支持顺序组合以及任意数量函数提升的类型构造函数。

Instances must satisfy the following laws in addition to the Applicative and Chain laws:
除了 ApplicativeChain 法则之外,实例还必须满足以下法则:

  1. Left identity: M.chain(M.of(a), f) <-> f(a) 左身份: M.chain(M.of(a), f) <-> f(a)
  2. Right identity: M.chain(fa, M.of) <-> fa 正确身份: M.chain(fa, M.of) <-> fa

Note. Functor’s map can be derived: A.map = (fa, f) => A.chain(fa, a => A.of(f(a)))
笔记。 Functor 的@​​1#可以推导出: A.map = (fa, f) => A.chain(fa, a => A.of(f(a)))

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Monad (interface)   单子(接口)

Signature 签名

export interface Monad<F> extends Applicative<F>, Chain<F> {}

Added in v2.0.0 v2.0.0 中添加

Monad1 (interface)   Monad1(接口)

Signature 签名

export interface Monad1<F extends URIS> extends Applicative1<F>, Chain1<F> {}

Added in v2.0.0 v2.0.0 中添加

Monad2 (interface)   Monad2(接口)

Signature 签名

export interface Monad2<M extends URIS2> extends Applicative2<M>, Chain2<M> {}

Added in v2.0.0 v2.0.0 中添加

Monad2C (interface)   Monad2C(接口)

Signature 签名

export interface Monad2C<M extends URIS2, L> extends Applicative2C<M, L>, Chain2C<M, L> {}

Added in v2.0.0 v2.0.0 中添加

Monad3 (interface)   Monad3(接口)

Signature 签名

export interface Monad3<M extends URIS3> extends Applicative3<M>, Chain3<M> {}

Added in v2.0.0 v2.0.0 中添加

Monad3C (interface)   Monad3C(接口)

Signature 签名

export interface Monad3C<M extends URIS3, E> extends Applicative3C<M, E>, Chain3C<M, E> {}

Added in v2.2.0 v2.2.0中添加

Monad4 (interface)   Monad4(接口)

Signature 签名

export interface Monad4<M extends URIS4> extends Applicative4<M>, Chain4<M> {}

Added in v2.0.0 v2.0.0 中添加

MonadIO overview  MonadIO 概述

Lift a computation from the IO monad
IO monad 提升计算

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

MonadIO (interface)   MonadIO(接口)

Signature 签名

export interface MonadIO<M> extends Monad<M>, FromIO<M> {}

Added in v2.0.0 v2.0.0 中添加

MonadIO1 (interface)   MonadIO1(接口)

Signature 签名

export interface MonadIO1<M extends URIS> extends Monad1<M>, FromIO1<M> {}

Added in v2.0.0 v2.0.0 中添加

MonadIO2 (interface)   MonadIO2(接口)

Signature 签名

export interface MonadIO2<M extends URIS2> extends Monad2<M>, FromIO2<M> {}

Added in v2.0.0 v2.0.0 中添加

MonadIO2C (interface)   MonadIO2C(接口)

Signature 签名

export interface MonadIO2C<M extends URIS2, E> extends Monad2C<M, E>, FromIO2C<M, E> {}

Added in v2.0.0 v2.0.0 中添加

MonadIO3 (interface)   MonadIO3(接口)

Signature 签名

export interface MonadIO3<M extends URIS3> extends Monad3<M>, FromIO3<M> {}

Added in v2.0.0 v2.0.0 中添加

MonadIO3C (interface)   MonadIO3C(接口)

Signature 签名

export interface MonadIO3C<M extends URIS3, E> extends Monad3C<M, E>, FromIO3C<M, E> {}

Added in v2.2.0 v2.2.0中添加

MonadIO4 (interface)   MonadIO4(接口)

Signature 签名

export interface MonadIO4<M extends URIS4> extends Monad4<M>, FromIO4<M> {}

Added in v2.4.4 v2.4.4 中添加

MonadTask overview  MonadTask 概述

Lift a computation from the Task monad
Task monad 提升计算

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

MonadTask (interface)   MonadTask(接口)

Signature 签名

export interface MonadTask<M> extends MonadIO<M>, FromTask<M> {}

Added in v2.0.0 v2.0.0 中添加

MonadTask1 (interface)   MonadTask1(接口)

Signature 签名

export interface MonadTask1<M extends URIS> extends MonadIO1<M>, FromTask1<M> {}

Added in v2.0.0 v2.0.0 中添加

MonadTask2 (interface)   MonadTask2(接口)

Signature 签名

export interface MonadTask2<M extends URIS2> extends MonadIO2<M>, FromTask2<M> {}

Added in v2.0.0 v2.0.0 中添加

MonadTask2C (interface)
MonadTask2C(接口)

Signature 签名

export interface MonadTask2C<M extends URIS2, E> extends MonadIO2C<M, E>, FromTask2C<M, E> {}

Added in v2.0.0 v2.0.0 中添加

MonadTask3 (interface)   MonadTask3(接口)

Signature 签名

export interface MonadTask3<M extends URIS3> extends MonadIO3<M>, FromTask3<M> {}

Added in v2.0.0 v2.0.0 中添加

MonadTask3C (interface)
MonadTask3C(接口)

Signature 签名

export interface MonadTask3C<M extends URIS3, E> extends MonadIO3C<M, E>, FromTask3C<M, E> {}

Added in v2.2.0 v2.2.0中添加

MonadTask4 (interface)   MonadTask4(接口)

Signature 签名

export interface MonadTask4<M extends URIS4> extends MonadIO4<M>, FromTask4<M> {}

Added in v2.4.4 v2.4.4 中添加

MonadThrow overview  MonadThrow 概述

The MonadThrow type class represents those monads which support errors via throwError, where throwError(e) halts, yielding the error e.
MonadThrow 类型类表示那些通过 throwError 支持错误的 monad,其中 throwError(e) 停止,产生错误 e

Laws: 法律:

  • Left zero: M.chain(M.throwError(e), f) = M.throwError(e) 左零: M.chain(M.throwError(e), f) = M.throwError(e)

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

MonadThrow (interface)   MonadThrow(接口)

Signature 签名

export interface MonadThrow<M> extends Monad<M> {
  readonly throwError: <E, A>(e: E) => HKT<M, A>
}

Added in v2.0.0 v2.0.0 中添加

MonadThrow1 (interface)
MonadThrow1(接口)

Signature 签名

export interface MonadThrow1<M extends URIS> extends Monad1<M> {
  readonly throwError: <E, A>(e: E) => Kind<M, A>
}

Added in v2.0.0 v2.0.0 中添加

MonadThrow2 (interface)
MonadThrow2(接口)

Signature 签名

export interface MonadThrow2<M extends URIS2> extends Monad2<M> {
  readonly throwError: <E, A>(e: E) => Kind2<M, E, A>
}

Added in v2.0.0 v2.0.0 中添加

MonadThrow2C (interface)
MonadThrow2C(接口)

Signature 签名

export interface MonadThrow2C<M extends URIS2, E> extends Monad2C<M, E> {
  readonly throwError: <A>(e: E) => Kind2<M, E, A>
}

Added in v2.0.0 v2.0.0 中添加

MonadThrow3 (interface)
MonadThrow3(接口)

Signature 签名

export interface MonadThrow3<M extends URIS3> extends Monad3<M> {
  readonly throwError: <R, E, A>(e: E) => Kind3<M, R, E, A>
}

Added in v2.0.0 v2.0.0 中添加

MonadThrow3C (interface)
MonadThrow3C(接口)

Signature 签名

export interface MonadThrow3C<M extends URIS3, E> extends Monad3C<M, E> {
  readonly throwError: <R, A>(e: E) => Kind3<M, R, E, A>
}

Added in v2.2.0 v2.2.0中添加

MonadThrow4 (interface)
MonadThrow4(接口)

Signature 签名

export interface MonadThrow4<M extends URIS4> extends Monad4<M> {
  readonly throwError: <S, R, E, A>(e: E) => Kind4<M, S, R, E, A>
}

Added in v2.0.0 v2.0.0 中添加

Monoid overview  幺半群概述

Monoid extends the power of Semigroup by providing an additional empty value.
Monoid 通过提供额外的 empty 值来扩展 Semigroup 的功能。

interface Semigroup<A> {
  readonly concat: (x: A, y: A) => A
}

interface Monoid<A> extends Semigroup<A> {
  readonly empty: A
}

This empty value should be an identity for the concat operation, which means the following equalities hold for any choice of x.
empty 值应该是 concat 操作的标识,这意味着以下等式适用于 x 的任何选择。

concat(x, empty) = concat(empty, x) = x

Many types that form a Semigroup also form a Monoid, such as numbers (with 0) and strings (with '').
许多形成 Semigroup 的类型也形成 Monoid ,例如 number s(与 0 )和 string s(与 '' )。

import { Monoid } from 'fp-ts/Monoid'

const monoidString: Monoid<string> = {
  concat: (x, y) => x + y,
  empty: '',
}

Adapted from https://typelevel.org/cats
改编自 https://typelevel.org/cats

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


constructors  构造函数

max   最大限度

Get a monoid where concat will return the maximum, based on the provided bounded order.
获取一个幺半群,其中 concat 将根据提供的有界顺序返回最大值。

The empty value is the bottom value.
empty 值是 bottom 值。

Signature 签名

export declare const max: <A>(B: Bounded<A>) => Monoid<A>

Example 例子

import * as N from 'fp-ts/number'
import * as M from 'fp-ts/Monoid'

const M1 = M.max(N.Bounded)

assert.deepStrictEqual(M1.concat(1, 2), 2)

Added in v2.10.0 v2.10.0 中添加

min   分钟

Get a monoid where concat will return the minimum, based on the provided bounded order.
获取一个幺半群,其中 concat 将根据提供的有界顺序返回最小值。

The empty value is the top value.
empty 值是 top 值。

Signature 签名

export declare const min: <A>(B: Bounded<A>) => Monoid<A>

Example 例子

import * as N from 'fp-ts/number'
import * as M from 'fp-ts/Monoid'

const M1 = M.min(N.Bounded)

assert.deepStrictEqual(M1.concat(1, 2), 1)

Added in v2.10.0 v2.10.0 中添加

model   模型

Monoid (interface)   幺半群(界面)

Signature 签名

export interface Monoid<A> extends Se.Semigroup<A> {
  readonly empty: A
}

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

concatAll   全部连接

Given a sequence of as, concat them and return the total.
给定一个 as 序列,将它们连接起来并返回总数。

If as is empty, return the monoid empty value.
如果 as 为空,则返回幺半群 empty 值。

Signature 签名

export declare const concatAll: <A>(M: Monoid<A>) => (as: readonly A[]) => A

Example 例子

import { concatAll } from 'fp-ts/Monoid'
import * as N from 'fp-ts/number'

assert.deepStrictEqual(concatAll(N.MonoidSum)([1, 2, 3]), 6)
assert.deepStrictEqual(concatAll(N.MonoidSum)([]), 0)

Added in v2.10.0 v2.10.0 中添加

reverse   撤销

The dual of a Monoid, obtained by swapping the arguments of concat.
Monoid 的对偶,通过交换 concat 的参数获得。

Signature 签名

export declare const reverse: <A>(M: Monoid<A>) => Monoid<A>

Example 例子

import { reverse } from 'fp-ts/Monoid'
import * as S from 'fp-ts/string'

assert.deepStrictEqual(reverse(S.Monoid).concat('a', 'b'), 'ba')

Added in v2.10.0 v2.10.0 中添加

struct   结构体

Given a struct of monoids returns a monoid for the struct.
给定一个幺半群结构,返回该结构的一个幺半群。

Signature 签名

export declare const struct: <A>(monoids: { [K in keyof A]: Monoid<A[K]> }) => Monoid<{ readonly [K in keyof A]: A[K] }>

Example 例子

import { struct } from 'fp-ts/Monoid'
import * as N from 'fp-ts/number'

interface Point {
  readonly x: number
  readonly y: number
}

const M = struct<Point>({
  x: N.MonoidSum,
  y: N.MonoidSum,
})

assert.deepStrictEqual(M.concat({ x: 1, y: 2 }, { x: 3, y: 4 }), { x: 4, y: 6 })

Added in v2.10.0 v2.10.0 中添加

tuple   元组

Given a tuple of monoids returns a monoid for the tuple.
给定一个幺半群元组,返回该元组的幺半群。

Signature 签名

export declare const tuple: <A extends readonly unknown[]>(
  ...monoids: { [K in keyof A]: Monoid<A[K]> }
) => Monoid<Readonly<A>>

Example 例子

import { tuple } from 'fp-ts/Monoid'
import * as B from 'fp-ts/boolean'
import * as N from 'fp-ts/number'
import * as S from 'fp-ts/string'

const M1 = tuple(S.Monoid, N.MonoidSum)
assert.deepStrictEqual(M1.concat(['a', 1], ['b', 2]), ['ab', 3])

const M2 = tuple(S.Monoid, N.MonoidSum, B.MonoidAll)
assert.deepStrictEqual(M2.concat(['a', 1, true], ['b', 2, false]), ['ab', 3, false])

Added in v2.10.0 v2.10.0 中添加

zone of death
死亡地带

fold 折叠

Use concatAll instead. 请改用 concatAll

Signature 签名

export declare const fold: <A>(M: Monoid<A>) => (as: readonly A[]) => A

Added in v2.0.0 v2.0.0 中添加

getDualMonoid 获取双Monoid

Use reverse instead. 请改用 reverse

Signature 签名

export declare const getDualMonoid: <A>(M: Monoid<A>) => Monoid<A>

Added in v2.0.0 v2.0.0 中添加

getEndomorphismMonoid 获取内同态Monoid

Use getEndomorphismMonoid instead. 请改用 getEndomorphismMonoid

Note. The execution order in getEndomorphismMonoid is reversed.
笔记。 getEndomorphismMonoid 中的执行顺序相反。

Signature 签名

export declare const getEndomorphismMonoid: <A = never>() => Monoid<Endomorphism<A>>

Added in v2.0.0 v2.0.0 中添加

getFunctionMonoid 获取函数Monoid

Use getMonoid instead. 请改用 getMonoid

Signature 签名

export declare const getFunctionMonoid: <M>(M: Monoid<M>) => <A = never>() => Monoid<(a: A) => M>

Added in v2.0.0 v2.0.0 中添加

getJoinMonoid 获取连接Monoid

Use max instead. 请改用 max

Signature 签名

export declare const getJoinMonoid: <A>(B: Bounded<A>) => Monoid<A>

Added in v2.0.0 v2.0.0 中添加

getMeetMonoid getMeetMonoid

Use min instead. 请改用 min

Signature 签名

export declare const getMeetMonoid: <A>(B: Bounded<A>) => Monoid<A>

Added in v2.0.0 v2.0.0 中添加

getStructMonoid 获取结构体Monoid

Use struct instead. 请改用 struct

Signature 签名

export declare const getStructMonoid: <O extends Readonly<Record<string, any>>>(monoids: {
  [K in keyof O]: Monoid<O[K]>
}) => Monoid<O>

Added in v2.0.0 v2.0.0 中添加

getTupleMonoid 获取元组Monoid

Use tuple instead. 请改用 tuple

Signature 签名

export declare const getTupleMonoid: <T extends readonly Monoid<any>[]>(
  ...monoids: T
) => Monoid<{ [K in keyof T]: T[K] extends Se.Semigroup<infer A> ? A : never }>

Added in v2.0.0 v2.0.0 中添加

monoidAll 幺半群

Use MonoidAll instead. 请改用 MonoidAll

Signature 签名

export declare const monoidAll: Monoid<boolean>

Added in v2.0.0 v2.0.0 中添加

monoidAny 幺半群

Use MonoidAny instead. 请改用 MonoidAny

Signature 签名

export declare const monoidAny: Monoid<boolean>

Added in v2.0.0 v2.0.0 中添加

monoidProduct 幺半群积

Use MonoidProduct instead. 请改用 MonoidProduct

Signature 签名

export declare const monoidProduct: Monoid<number>

Added in v2.0.0 v2.0.0 中添加

monoidString 幺半群字符串

Use Monoid instead. 请改用 Monoid

Signature 签名

export declare const monoidString: Monoid<string>

Added in v2.0.0 v2.0.0 中添加

monoidSum 幺半群和

Use MonoidSum instead. 请改用 MonoidSum

Signature 签名

export declare const monoidSum: Monoid<number>

Added in v2.0.0 v2.0.0 中添加

monoidVoid 幺半群虚空

Use Monoid instead. 请改用 Monoid

Signature 签名

export declare const monoidVoid: Monoid<void>

Added in v2.0.0 v2.0.0 中添加

NaturalTransformation overview
自然变换概述

A type for natural transformations.
自然变换的类型。

A natural transformation is a mapping between type constructors of kind * -> * where the mapping operation has no ability to manipulate the inner values.
自然转换是 * -> * 类型构造函数之间的映射,其中映射操作无法操作内部值。

The definition of a natural transformation in category theory states that F and G should be functors, but the Functor constraint is not enforced here; that the types are of kind * -> * is enough for our purposes.
范畴论中自然变换的定义规定 FG 应该是函子,但这里不强制执行 Functor 约束;对于我们的目的来说,类型是 * -> * 就足够了。

Added in v2.11.0 v2.11.0 中添加


Table of contents
目录


utils   实用程序

NaturalTransformation (interface)
自然变换(界面)

Signature 签名

export interface NaturalTransformation<F, G> {
  <A>(fa: HKT<F, A>): HKT<G, A>
}

Added in v2.11.0 v2.11.0 中添加

NaturalTransformation11 (interface)
NaturalTransformation11(界面)

Signature 签名

export interface NaturalTransformation11<F extends URIS, G extends URIS> {
  <A>(fa: Kind<F, A>): Kind<G, A>
}

Added in v2.11.0 v2.11.0 中添加

NaturalTransformation12 (interface)
NaturalTransformation12(界面)

Signature 签名

export interface NaturalTransformation12<F extends URIS, G extends URIS2> {
  <A, E>(fa: Kind<F, A>): Kind2<G, E, A>
}

Added in v2.11.0 v2.11.0 中添加

NaturalTransformation12C (interface)
NaturalTransformation12C(接口)

Signature 签名

export interface NaturalTransformation12C<F extends URIS, G extends URIS2, E> {
  <A>(fa: Kind<F, A>): Kind2<G, E, A>
}

Added in v2.11.0 v2.11.0 中添加

NaturalTransformation13 (interface)
NaturalTransformation13(界面)

Signature 签名

export interface NaturalTransformation13<F extends URIS, G extends URIS3> {
  <A, R, E>(fa: Kind<F, A>): Kind3<G, R, E, A>
}

Added in v2.11.0 v2.11.0 中添加

NaturalTransformation13C (interface)
NaturalTransformation13C(接口)

Signature 签名

export interface NaturalTransformation13C<F extends URIS, G extends URIS3, E> {
  <A, R>(fa: Kind<F, A>): Kind3<G, R, E, A>
}

Added in v2.11.0 v2.11.0 中添加

NaturalTransformation14 (interface)
NaturalTransformation14(界面)

Signature 签名

export interface NaturalTransformation14<F extends URIS, G extends URIS4> {
  <A, S, R, E>(fa: Kind<F, A>): Kind4<G, S, R, E, A>
}

Added in v2.11.0 v2.11.0 中添加

NaturalTransformation14C (interface)
NaturalTransformation14C(接口)

Signature 签名

export interface NaturalTransformation14C<F extends URIS, G extends URIS4, E> {
  <A, S, R>(fa: Kind<F, A>): Kind4<G, S, R, E, A>
}

Added in v2.11.0 v2.11.0 中添加

NaturalTransformation21 (interface)
NaturalTransformation21(界面)

Signature 签名

export interface NaturalTransformation21<F extends URIS2, G extends URIS> {
  <A>(fa: Kind2<F, unknown, A>): Kind<G, A>
}

Added in v2.11.0 v2.11.0 中添加

NaturalTransformation22 (interface)
NaturalTransformation22(界面)

Signature 签名

export interface NaturalTransformation22<F extends URIS2, G extends URIS2> {
  <E, A>(fa: Kind2<F, E, A>): Kind2<G, E, A>
}

Added in v2.11.0 v2.11.0 中添加

NaturalTransformation22C (interface)
NaturalTransformation22C(接口)

Signature 签名

export interface NaturalTransformation22C<F extends URIS2, G extends URIS2, E> {
  <A>(fa: Kind2<F, E, A>): Kind2<G, E, A>
}

Added in v2.11.0 v2.11.0 中添加

NaturalTransformation23 (interface)
NaturalTransformation23(界面)

Signature 签名

export interface NaturalTransformation23<F extends URIS2, G extends URIS3> {
  <E, A, R>(fa: Kind2<F, E, A>): Kind3<G, R, E, A>
}

Added in v2.11.0 v2.11.0 中添加

NaturalTransformation23C (interface)
NaturalTransformation23C(接口)

Signature 签名

export interface NaturalTransformation23C<F extends URIS2, G extends URIS3, E> {
  <A, R>(fa: Kind2<F, E, A>): Kind3<G, R, E, A>
}

Added in v2.11.0 v2.11.0 中添加

NaturalTransformation23R (interface)
NaturalTransformation23R(接口)

Signature 签名

export interface NaturalTransformation23R<F extends URIS2, G extends URIS3> {
  <R, A, E>(fa: Kind2<F, R, A>): Kind3<G, R, E, A>
}

Added in v2.11.0 v2.11.0 中添加

NaturalTransformation23RC (interface)
NaturalTransformation23RC(接口)

Signature 签名

export interface NaturalTransformation23RC<F extends URIS2, G extends URIS3, E> {
  <R, A>(fa: Kind2<F, R, A>): Kind3<G, R, E, A>
}

Added in v2.11.0 v2.11.0 中添加

NaturalTransformation24 (interface)
NaturalTransformation24(界面)

Signature 签名

export interface NaturalTransformation24<F extends URIS2, G extends URIS4> {
  <E, A, S, R>(fa: Kind2<F, E, A>): Kind4<G, S, R, E, A>
}

Added in v2.11.0 v2.11.0 中添加

NaturalTransformation24R (interface)
NaturalTransformation24R(接口)

Signature 签名

export interface NaturalTransformation24R<F extends URIS2, G extends URIS4> {
  <R, A, S, E>(fa: Kind2<F, R, A>): Kind4<G, S, R, E, A>
}

Added in v2.11.0 v2.11.0 中添加

NaturalTransformation24S (interface)
NaturalTransformation24S(界面)

Signature 签名

export interface NaturalTransformation24S<F extends URIS2, G extends URIS4> {
  <S, A, R, E>(fa: Kind2<F, S, A>): Kind4<G, S, R, E, A>
}

Added in v2.11.0 v2.11.0 中添加

NaturalTransformation33 (interface)
NaturalTransformation33(界面)

Signature 签名

export interface NaturalTransformation33<F extends URIS3, G extends URIS3> {
  <R, E, A>(fa: Kind3<F, R, E, A>): Kind3<G, R, E, A>
}

Added in v2.11.0 v2.11.0 中添加

NaturalTransformation34 (interface)
NaturalTransformation34(界面)

Signature 签名

export interface NaturalTransformation34<F extends URIS3, G extends URIS4> {
  <R, E, A, S>(fa: Kind3<F, R, E, A>): Kind4<G, S, R, E, A>
}

Added in v2.11.0 v2.11.0 中添加

NonEmptyArray overview  非空数组概述

Data structure which represents non-empty arrays.
表示非空数组的数据结构。

export type NonEmptyArray<A> = Array<A> & {
  0: A
}

Note that you don’t need any conversion, a NonEmptyArray is an Array, so all Array’s APIs can be used with a NonEmptyArray without further ado.
请注意,您不需要任何转换, NonEmptyArray 就是 Array ,因此所有 Array 的 API 都可以与 NonEmptyArray 一起使用,无需多言。

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


constructors  构造函数

makeBy  制造者

Return a NonEmptyArray of length n with element i initialized with f(i).
返回长度为 nNonEmptyArray ,其中元素 if(i) 初始化。

Note. n is normalized to a natural number.
笔记。 n 标准化为自然数。

Signature 签名

export declare const makeBy: <A>(f: (i: number) => A) => (n: number) => NonEmptyArray<A>

Example 例子

import { makeBy } from 'fp-ts/NonEmptyArray'
import { pipe } from 'fp-ts/function'

const double = (n: number): number => n * 2
assert.deepStrictEqual(pipe(5, makeBy(double)), [0, 2, 4, 6, 8])

Added in v2.11.0 v2.11.0 中添加

of  

Signature 签名

export declare const of: <A>(a: A) => NonEmptyArray<A>

Added in v2.0.0 v2.0.0 中添加

range   范围

Create a NonEmptyArray containing a range of integers, including both endpoints.
创建一个包含一系列整数的 NonEmptyArray ,包括两个端点。

Signature 签名

export declare const range: (start: number, end: number) => NonEmptyArray<number>

Example 例子

import { range } from 'fp-ts/NonEmptyArray'

assert.deepStrictEqual(range(1, 5), [1, 2, 3, 4, 5])

Added in v2.11.0 v2.11.0 中添加

replicate   复制

Create a NonEmptyArray containing a value repeated the specified number of times.
创建一个包含重复指定次数的值的 NonEmptyArray

Note. n is normalized to a natural number.
笔记。 n 标准化为自然数。

Signature 签名

export declare const replicate: <A>(a: A) => (n: number) => RNEA.ReadonlyNonEmptyArray<A>

Example 例子

import { replicate } from 'fp-ts/NonEmptyArray'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe(3, replicate('a')), ['a', 'a', 'a'])

Added in v2.11.0 v2.11.0 中添加

conversions   转换

fromArray   来自数组

Builds a NonEmptyArray from an Array returning none if as is an empty array
如果 as 是空数组,则从 Array 构建 NonEmptyArray 返回 none

Signature 签名

export declare const fromArray: <A>(as: A[]) => Option<NonEmptyArray<A>>

Added in v2.0.0 v2.0.0 中添加

fromReadonlyNonEmptyArray
来自ReadonlyNonEmptyArray

Signature 签名

export declare const fromReadonlyNonEmptyArray: <A>(as: RNEA.ReadonlyNonEmptyArray<A>) => NonEmptyArray<A>

Added in v2.10.0 v2.10.0 中添加

do notation   做记号

Do  

Signature 签名

export declare const Do: NonEmptyArray<{}>

Added in v2.9.0 v2.9.0中添加

apS   apS

Signature 签名

export declare const apS: <N, A, B>(
  name: Exclude<N, keyof A>,
  fb: NonEmptyArray<B>
) => (fa: NonEmptyArray<A>) => NonEmptyArray<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bind   绑定

Signature 签名

export declare const bind: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => NonEmptyArray<B>
) => (ma: NonEmptyArray<A>) => NonEmptyArray<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bindTo   绑定到

Signature 签名

export declare const bindTo: <N>(name: N) => <A>(fa: NonEmptyArray<A>) => NonEmptyArray<{ readonly [K in N]: A }>

Added in v2.8.0 v2.8.0 中添加

let  

Signature 签名

export declare const let: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => (fa: NonEmptyArray<A>) => NonEmptyArray<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.13.0 v2.13.0 中添加

error handling   错误处理

alt   替代

Identifies an associative operation on a type constructor. It is similar to Semigroup, except that it applies to types of kind * -> *.
标识类型构造函数上的关联操作。它与 Semigroup 类似,但它适用于 * -> * 类型。

In case of NonEmptyArray concatenates the inputs into a single array.
如果是 NonEmptyArray ,则将输入连接到单个数组中。

Signature 签名

export declare const alt: <A>(that: LazyArg<NonEmptyArray<A>>) => (fa: NonEmptyArray<A>) => NonEmptyArray<A>

Example 例子

import * as NEA from 'fp-ts/NonEmptyArray'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(
  pipe(
    [1, 2, 3],
    NEA.alt(() => [4, 5])
  ),
  [1, 2, 3, 4, 5]
)

Added in v2.6.2 v2.6.2 中添加

altW   替代W

Less strict version of alt.
alt 的不太严格版本。

The W suffix (short for Widening) means that the return types will be merged.
W 后缀(Widening 的缩写)意味着返回类型将被合并。

Signature 签名

export declare const altW: <B>(that: LazyArg<NonEmptyArray<B>>) => <A>(as: NonEmptyArray<A>) => NonEmptyArray<B | A>

Example 例子

import * as NEA from 'fp-ts/NonEmptyArray'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(
  pipe(
    [1, 2, 3] as NEA.NonEmptyArray<number>,
    NEA.altW(() => ['a', 'b'])
  ),
  [1, 2, 3, 'a', 'b']
)

Added in v2.9.0 v2.9.0中添加

folding   折叠式的

foldMap   折叠图

Signature 签名

export declare const foldMap: <S>(S: Se.Semigroup<S>) => <A>(f: (a: A) => S) => (fa: NonEmptyArray<A>) => S

Added in v2.0.0 v2.0.0 中添加

foldMapWithIndex   带索引的折叠地图

Signature 签名

export declare const foldMapWithIndex: <S>(
  S: Se.Semigroup<S>
) => <A>(f: (i: number, a: A) => S) => (fa: NonEmptyArray<A>) => S

Added in v2.0.0 v2.0.0 中添加

reduce   减少

Signature 签名

export declare const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: NonEmptyArray<A>) => B

Added in v2.0.0 v2.0.0 中添加

reduceRight   减少右

Signature 签名

export declare const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: NonEmptyArray<A>) => B

Added in v2.0.0 v2.0.0 中添加

reduceRightWithIndex   减少右索引

Signature 签名

export declare const reduceRightWithIndex: <A, B>(b: B, f: (i: number, a: A, b: B) => B) => (fa: NonEmptyArray<A>) => B

Added in v2.0.0 v2.0.0 中添加

reduceWithIndex  减少索引

Signature 签名

export declare const reduceWithIndex: <A, B>(b: B, f: (i: number, b: B, a: A) => B) => (fa: NonEmptyArray<A>) => B

Added in v2.0.0 v2.0.0 中添加

instances   实例

Alt   替代

Signature 签名

export declare const Alt: Alt1<'NonEmptyArray'>

Added in v2.7.0 v2.7.0 中添加

Applicative   适用性

Signature 签名

export declare const Applicative: Applicative1<'NonEmptyArray'>

Added in v2.7.0 v2.7.0 中添加

Apply   申请

Signature 签名

export declare const Apply: Apply1<'NonEmptyArray'>

Added in v2.10.0 v2.10.0 中添加

Chain  

Signature 签名

export declare const Chain: Chain1<'NonEmptyArray'>

Added in v2.10.0 v2.10.0 中添加

Comonad   科莫纳德

Signature 签名

export declare const Comonad: Comonad1<'NonEmptyArray'>

Added in v2.7.0 v2.7.0 中添加

Foldable   折叠式

Signature 签名

export declare const Foldable: Foldable1<'NonEmptyArray'>

Added in v2.7.0 v2.7.0 中添加

FoldableWithIndex   可折叠带索引

Signature 签名

export declare const FoldableWithIndex: FoldableWithIndex1<'NonEmptyArray', number>

Added in v2.7.0 v2.7.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor1<'NonEmptyArray'>

Added in v2.7.0 v2.7.0 中添加

FunctorWithIndex   带索引的函子

Signature 签名

export declare const FunctorWithIndex: FunctorWithIndex1<'NonEmptyArray', number>

Added in v2.7.0 v2.7.0 中添加

Monad   单子

Signature 签名

export declare const Monad: Monad1<'NonEmptyArray'>

Added in v2.7.0 v2.7.0 中添加

Pointed  

Signature 签名

export declare const Pointed: Pointed1<'NonEmptyArray'>

Added in v2.10.0 v2.10.0 中添加

Traversable   可穿越

Signature 签名

export declare const Traversable: Traversable1<'NonEmptyArray'>

Added in v2.7.0 v2.7.0 中添加

TraversableWithIndex   可遍历索引

Signature 签名

export declare const TraversableWithIndex: TraversableWithIndex1<'NonEmptyArray', number>

Added in v2.7.0 v2.7.0 中添加

getEq   得到方程

Signature 签名

export declare const getEq: <A>(E: Eq<A>) => Eq<NonEmptyArray<A>>

Example 例子

import { getEq } from 'fp-ts/NonEmptyArray'
import * as N from 'fp-ts/number'

const E = getEq(N.Eq)
assert.strictEqual(E.equals([1, 2], [1, 2]), true)
assert.strictEqual(E.equals([1, 2], [1, 3]), false)

Added in v2.0.0 v2.0.0 中添加

getSemigroup   获取半群

Builds a Semigroup instance for NonEmptyArray
NonEmptyArray 构建一个 Semigroup 实例

Signature 签名

export declare const getSemigroup: <A = never>() => Se.Semigroup<NonEmptyArray<A>>

Added in v2.0.0 v2.0.0 中添加

getShow   获取显示

Signature 签名

export declare const getShow: <A>(S: Show<A>) => Show<NonEmptyArray<A>>

Added in v2.0.0 v2.0.0 中添加

legacy   遗产

chain  

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chain: <A, B>(f: (a: A) => NonEmptyArray<B>) => (ma: NonEmptyArray<A>) => NonEmptyArray<B>

Added in v2.0.0 v2.0.0 中添加

mapping   映射

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <B>(fab: NonEmptyArray<(a: A) => B>) => NonEmptyArray<B>

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => (as: NonEmptyArray<A>) => NonEmptyArray<B>

Added in v2.0.0 v2.0.0 中添加

mapWithIndex   带索引的映射

Signature 签名

export declare const mapWithIndex: <A, B>(f: (i: number, a: A) => B) => (as: NonEmptyArray<A>) => NonEmptyArray<B>

Added in v2.0.0 v2.0.0 中添加

model   模型

NonEmptyArray (interface)
非空数组(接口)

Signature 签名

export interface NonEmptyArray<A> extends Array<A> {
  0: A
}

Added in v2.0.0 v2.0.0 中添加

pattern matching   模式匹配

matchLeft   左匹配

Break an Array into its first element and remaining elements.
Array 分解为其第一个元素和其余元素。

Signature 签名

export declare const matchLeft: <A, B>(f: (head: A, tail: A[]) => B) => (as: NonEmptyArray<A>) => B

Added in v2.11.0 v2.11.0 中添加

matchRight   右匹配

Break an Array into its initial elements and the last element.
Array 分解为其初始元素和最后一个元素。

Signature 签名

export declare const matchRight: <A, B>(f: (init: A[], last: A) => B) => (as: NonEmptyArray<A>) => B

Added in v2.11.0 v2.11.0 中添加

sequencing   测序

chainFirst   链优先

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const chainFirst: <A, B>(f: (a: A) => NonEmptyArray<B>) => (first: NonEmptyArray<A>) => NonEmptyArray<A>

Added in v2.5.0 v2.5.0中添加

chainWithIndex   带索引的链

Signature 签名

export declare const chainWithIndex: <A, B>(
  f: (i: number, a: A) => NonEmptyArray<B>
) => (as: NonEmptyArray<A>) => NonEmptyArray<B>

Added in v2.10.0 v2.10.0 中添加

flatMap   平面地图

Signature 签名

export declare const flatMap: {
  <A, B>(f: (a: A, i: number) => NonEmptyArray<B>): (ma: NonEmptyArray<A>) => NonEmptyArray<B>
  <A, B>(ma: NonEmptyArray<A>, f: (a: A, i: number) => NonEmptyArray<B>): NonEmptyArray<B>
}

Example 例子

import * as NEA from 'fp-ts/NonEmptyArray'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(
  pipe(
    [1, 2, 3],
    NEA.flatMap((n) => [`a${n}`, `b${n}`])
  ),
  ['a1', 'b1', 'a2', 'b2', 'a3', 'b3']
)

Added in v2.14.0 v2.14.0 中添加

flatten   压扁

Signature 签名

export declare const flatten: <A>(mma: NonEmptyArray<NonEmptyArray<A>>) => NonEmptyArray<A>

Added in v2.5.0 v2.5.0中添加

traverseWithIndex   索引遍历

Signature 签名

export declare const traverseWithIndex: PipeableTraverseWithIndex1<'NonEmptyArray', number>

Added in v2.6.3 v2.6.3 中添加

traversing   穿越

sequence   顺序

Signature 签名

export declare const sequence: Sequence1<'NonEmptyArray'>

Added in v2.6.3 v2.6.3 中添加

traverse   遍历

Signature 签名

export declare const traverse: PipeableTraverse1<'NonEmptyArray'>

Added in v2.6.3 v2.6.3 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'NonEmptyArray'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

ap   美联社

Apply a function to an argument under a type constructor.
将函数应用于类型构造函数下的参数。

Signature 签名

export declare const ap: <A>(as: NonEmptyArray<A>) => <B>(fab: NonEmptyArray<(a: A) => B>) => NonEmptyArray<B>

Added in v2.0.0 v2.0.0 中添加

apFirst   应用程序第一

Combine two effectful actions, keeping only the result of the first.
结合两个有效的操作,仅保留第一个操作的结果。

Signature 签名

export declare const apFirst: <B>(second: NonEmptyArray<B>) => <A>(first: NonEmptyArray<A>) => NonEmptyArray<A>

Added in v2.5.0 v2.5.0中添加

apSecond   ap秒

Combine two effectful actions, keeping only the result of the second.
结合两个有效的操作,只保留第二个的结果。

Signature 签名

export declare const apSecond: <B>(second: NonEmptyArray<B>) => <A>(first: NonEmptyArray<A>) => NonEmptyArray<B>

Added in v2.5.0 v2.5.0中添加

chop  

Signature 签名

export declare const chop: <A, B>(f: (as: NonEmptyArray<A>) => [B, A[]]) => (as: NonEmptyArray<A>) => NonEmptyArray<B>

Added in v2.10.0 v2.10.0 中添加

chunksOf   大块

Signature 签名

export declare const chunksOf: (n: number) => <A>(as: NonEmptyArray<A>) => NonEmptyArray<NonEmptyArray<A>>

Added in v2.10.0 v2.10.0 中添加

concat   连接

Signature 签名

export declare function concat<A>(second: NonEmptyArray<A>): (first: Array<A>) => NonEmptyArray<A>
export declare function concat<A>(second: Array<A>): (first: NonEmptyArray<A>) => NonEmptyArray<A>
export declare function concat<A>(first: Array<A>, second: NonEmptyArray<A>): NonEmptyArray<A>
export declare function concat<A>(first: NonEmptyArray<A>, second: Array<A>): NonEmptyArray<A>

Added in v2.2.0 v2.2.0中添加

concatAll   全部连接

Signature 签名

export declare const concatAll: <A>(S: Se.Semigroup<A>) => (as: NonEmptyArray<A>) => A

Added in v2.10.0 v2.10.0 中添加

concatW   连接W

Signature 签名

export declare function concatW<B>(second: NonEmptyArray<B>): <A>(first: Array<A>) => NonEmptyArray<A | B>
export declare function concatW<B>(second: Array<B>): <A>(first: NonEmptyArray<A>) => NonEmptyArray<A | B>

Added in v2.11.0 v2.11.0 中添加

copy   复制

Signature 签名

export declare const copy: <A>(as: NonEmptyArray<A>) => NonEmptyArray<A>

Added in v2.0.0 v2.0.0 中添加

duplicate   复制

Signature 签名

export declare const duplicate: <A>(ma: NonEmptyArray<A>) => NonEmptyArray<NonEmptyArray<A>>

Added in v2.5.0 v2.5.0中添加

extend   延长

Signature 签名

export declare const extend: <A, B>(f: (as: NonEmptyArray<A>) => B) => (as: NonEmptyArray<A>) => NonEmptyArray<B>

Added in v2.0.0 v2.0.0 中添加

extract   提炼

Signature 签名

export declare const extract: <A>(wa: NonEmptyArray<A>) => A

Added in v2.7.0 v2.7.0 中添加

getUnionSemigroup   获取UnionSemigroup

Signature 签名

export declare const getUnionSemigroup: <A>(E: Eq<A>) => Se.Semigroup<NonEmptyArray<A>>

Added in v2.11.0 v2.11.0 中添加

group   团体

Group equal, consecutive elements of an array into non empty arrays.
将数组中相等的连续元素分组为非空数组。

Signature 签名

export declare function group<B>(E: Eq<B>): {
  <A extends B>(as: NonEmptyArray<A>): NonEmptyArray<NonEmptyArray<A>>
  <A extends B>(as: Array<A>): Array<NonEmptyArray<A>>
}

Example 例子

import { group } from 'fp-ts/NonEmptyArray'
import * as N from 'fp-ts/number'

assert.deepStrictEqual(group(N.Ord)([1, 2, 1, 1]), [[1], [2], [1, 1]])

Added in v2.0.0 v2.0.0 中添加

groupBy   通过...分组

Splits an array into sub-non-empty-arrays stored in an object, based on the result of calling a string-returning function on each element, and grouping the results according to values returned
根据对每个元素调用 string 返回函数的结果,将数组拆分为存储在对象中的子非空数组,并根据返回的值对结果进行分组

Signature 签名

export declare const groupBy: <A>(f: (a: A) => string) => (as: A[]) => Record<string, NonEmptyArray<A>>

Example 例子

import { groupBy } from 'fp-ts/NonEmptyArray'

assert.deepStrictEqual(groupBy((s: string) => String(s.length))(['a', 'b', 'ab']), {
  '1': ['a', 'b'],
  '2': ['ab'],
})

Added in v2.0.0 v2.0.0 中添加

Signature 签名

export declare const head: <A>(nea: NonEmptyArray<A>) => A

Added in v2.0.0 v2.0.0 中添加

init   在里面

Get all but the last element of a non empty array, creating a new array.
获取非空数组中除最后一个元素之外的所有元素,创建一个新数组。

Signature 签名

export declare const init: <A>(as: NonEmptyArray<A>) => A[]

Example 例子

import { init } from 'fp-ts/NonEmptyArray'

assert.deepStrictEqual(init([1, 2, 3]), [1, 2])
assert.deepStrictEqual(init([1]), [])

Added in v2.2.0 v2.2.0中添加

insertAt   插入位置

Signature 签名

export declare const insertAt: <A>(i: number, a: A) => (as: A[]) => Option<NonEmptyArray<A>>

Added in v2.0.0 v2.0.0 中添加

intercalate  

Places an element in between members of a NonEmptyArray, then folds the results using the provided Semigroup.
将一个元素放置在 NonEmptyArray 的成员之间,然后使用提供的 Semigroup 折叠结果。

Signature 签名

export declare const intercalate: <A>(S: Se.Semigroup<A>) => (middle: A) => (as: NonEmptyArray<A>) => A

Example 例子

import * as S from 'fp-ts/string'
import { intercalate } from 'fp-ts/NonEmptyArray'

assert.deepStrictEqual(intercalate(S.Semigroup)('-')(['a', 'b', 'c']), 'a-b-c')

Added in v2.12.0 v2.12.0 中添加

intersperse   散布

Places an element in between members of an array
将元素放置在数组成员之间

Signature 签名

export declare const intersperse: <A>(middle: A) => (as: NonEmptyArray<A>) => NonEmptyArray<A>

Example 例子

import { intersperse } from 'fp-ts/NonEmptyArray'

assert.deepStrictEqual(intersperse(9)([1, 2, 3, 4]), [1, 9, 2, 9, 3, 9, 4])

Added in v2.9.0 v2.9.0中添加

last   最后的

Signature 签名

export declare const last: <A>(nea: NonEmptyArray<A>) => A

Added in v2.0.0 v2.0.0 中添加

max   最大限度

Signature 签名

export declare const max: <A>(ord: Ord<A>) => (nea: NonEmptyArray<A>) => A

Added in v2.0.0 v2.0.0 中添加

min   分钟

Signature 签名

export declare const min: <A>(ord: Ord<A>) => (nea: NonEmptyArray<A>) => A

Added in v2.0.0 v2.0.0 中添加

modifyAt   修改处

Signature 签名

export declare const modifyAt: <A>(i: number, f: (a: A) => A) => (as: NonEmptyArray<A>) => Option<NonEmptyArray<A>>

Added in v2.0.0 v2.0.0 中添加

modifyHead   修改头

Apply a function to the head, creating a new NonEmptyArray.
将函数应用于头部,创建一个新的 NonEmptyArray

Signature 签名

export declare const modifyHead: <A>(f: Endomorphism<A>) => (as: NonEmptyArray<A>) => NonEmptyArray<A>

Added in v2.11.0 v2.11.0 中添加

modifyLast   修改最后一个

Apply a function to the last element, creating a new NonEmptyArray.
将函数应用于最后一个元素,创建一个新的 NonEmptyArray

Signature 签名

export declare const modifyLast: <A>(f: Endomorphism<A>) => (as: NonEmptyArray<A>) => NonEmptyArray<A>

Added in v2.11.0 v2.11.0 中添加

prependAll   前置所有

Prepend an element to every member of an array
为数组的每个成员添加一个元素

Signature 签名

export declare const prependAll: <A>(middle: A) => (as: NonEmptyArray<A>) => NonEmptyArray<A>

Example 例子

import { prependAll } from 'fp-ts/NonEmptyArray'

assert.deepStrictEqual(prependAll(9)([1, 2, 3, 4]), [9, 1, 9, 2, 9, 3, 9, 4])

Added in v2.10.0 v2.10.0 中添加

reverse   撤销

Signature 签名

export declare const reverse: <A>(as: NonEmptyArray<A>) => NonEmptyArray<A>

Added in v2.0.0 v2.0.0 中添加

rotate   旋转

Rotate a NonEmptyArray by n steps.
NonEmptyArray 旋转 n 步。

Signature 签名

export declare const rotate: (n: number) => <A>(as: NonEmptyArray<A>) => NonEmptyArray<A>

Example 例子

import { rotate } from 'fp-ts/NonEmptyArray'

assert.deepStrictEqual(rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])
assert.deepStrictEqual(rotate(-2)([1, 2, 3, 4, 5]), [3, 4, 5, 1, 2])

Added in v2.11.0 v2.11.0 中添加

sort   种类

Signature 签名

export declare const sort: <B>(O: Ord<B>) => <A extends B>(as: NonEmptyArray<A>) => NonEmptyArray<A>

Added in v2.0.0 v2.0.0 中添加

sortBy   排序方式

Sort the elements of a NonEmptyArray in increasing order, where elements are compared using first ords[0], then ords[1], etc…
按升序对 NonEmptyArray 的元素进行排序,其中首先使用 ords[0] 比较元素,然后使用 ords[1] 等进行比较...

Signature 签名

export declare const sortBy: <B>(ords: Ord<B>[]) => <A extends B>(as: NonEmptyArray<A>) => NonEmptyArray<A>

Example 例子

import * as NEA from 'fp-ts/NonEmptyArray'
import { contramap } from 'fp-ts/Ord'
import * as S from 'fp-ts/string'
import * as N from 'fp-ts/number'
import { pipe } from 'fp-ts/function'

interface Person {
  name: string
  age: number
}

const byName = pipe(
  S.Ord,
  contramap((p: Person) => p.name)
)

const byAge = pipe(
  N.Ord,
  contramap((p: Person) => p.age)
)

const sortByNameByAge = NEA.sortBy([byName, byAge])

const persons: NEA.NonEmptyArray<Person> = [
  { name: 'a', age: 1 },
  { name: 'b', age: 3 },
  { name: 'c', age: 2 },
  { name: 'b', age: 2 },
]

assert.deepStrictEqual(sortByNameByAge(persons), [
  { name: 'a', age: 1 },
  { name: 'b', age: 2 },
  { name: 'b', age: 3 },
  { name: 'c', age: 2 },
])

Added in v2.11.0 v2.11.0 中添加

splitAt   分割点

Splits a NonEmptyArray into two pieces, the first piece has max n elements.
NonEmptyArray 分成两部分,第一部分最多包含 n 元素。

Signature 签名

export declare const splitAt: (n: number) => <A>(as: NonEmptyArray<A>) => [NonEmptyArray<A>, A[]]

Added in v2.10.0 v2.10.0 中添加

tail   尾巴

Signature 签名

export declare const tail: <A>(as: NonEmptyArray<A>) => A[]

Added in v2.0.0 v2.0.0 中添加

unappend   取消附加

Return the tuple of the init and the last.
返回 initlast 的元组。

Signature 签名

export declare const unappend: <A>(as: NonEmptyArray<A>) => [A[], A]

Example 例子

import { unappend } from 'fp-ts/NonEmptyArray'

assert.deepStrictEqual(unappend([1, 2, 3, 4]), [[1, 2, 3], 4])

Added in v2.9.0 v2.9.0中添加

union   联盟

Signature 签名

export declare const union: <A>(E: Eq<A>) => (second: NonEmptyArray<A>) => (first: NonEmptyArray<A>) => NonEmptyArray<A>

Added in v2.11.0 v2.11.0 中添加

uniq   独特的

Remove duplicates from a NonEmptyArray, keeping the first occurrence of an element.
NonEmptyArray 中删除重复项,保留元素的第一次出现。

Signature 签名

export declare const uniq: <A>(E: Eq<A>) => (as: NonEmptyArray<A>) => NonEmptyArray<A>

Example 例子

import { uniq } from 'fp-ts/NonEmptyArray'
import * as N from 'fp-ts/number'

assert.deepStrictEqual(uniq(N.Eq)([1, 2, 1]), [1, 2])

Added in v2.11.0 v2.11.0 中添加

unprepend   取消前置

Return the tuple of the head and the tail.
返回 headtail 的元组。

Signature 签名

export declare const unprepend: <A>(as: NonEmptyArray<A>) => [A, A[]]

Example 例子

import { unprepend } from 'fp-ts/NonEmptyArray'

assert.deepStrictEqual(unprepend([1, 2, 3]), [1, [2, 3]])

Added in v2.9.0 v2.9.0中添加

unzip   解压

Signature 签名

export declare const unzip: <A, B>(abs: NonEmptyArray<[A, B]>) => [NonEmptyArray<A>, NonEmptyArray<B>]

Added in v2.5.1 v2.5.1 中添加

updateAt   更新时间

Signature 签名

export declare const updateAt: <A>(i: number, a: A) => (as: NonEmptyArray<A>) => Option<NonEmptyArray<A>>

Added in v2.0.0 v2.0.0 中添加

updateHead   更新头

Change the head, creating a new NonEmptyArray.
更改头部,创建一个新的 NonEmptyArray

Signature 签名

export declare const updateHead: <A>(a: A) => (as: NonEmptyArray<A>) => NonEmptyArray<A>

Added in v2.11.0 v2.11.0 中添加

updateLast   更新最后

Change the last element, creating a new NonEmptyArray.
更改最后一个元素,创建一个新的 NonEmptyArray

Signature 签名

export declare const updateLast: <A>(a: A) => (as: NonEmptyArray<A>) => NonEmptyArray<A>

Added in v2.11.0 v2.11.0 中添加

zip   压缩

Signature 签名

export declare function zip<B>(bs: NonEmptyArray<B>): <A>(as: NonEmptyArray<A>) => NonEmptyArray<[A, B]>
export declare function zip<A, B>(as: NonEmptyArray<A>, bs: NonEmptyArray<B>): NonEmptyArray<[A, B]>

Added in v2.5.1 v2.5.1 中添加

zipWith   zipWith

Signature 签名

export declare const zipWith: <A, B, C>(
  as: NonEmptyArray<A>,
  bs: NonEmptyArray<B>,
  f: (a: A, b: B) => C
) => NonEmptyArray<C>

Added in v2.5.1 v2.5.1 中添加

zone of death
死亡地带

cons 缺点

Use prepend instead. 请改用 prepend

Signature 签名

export declare function cons<A>(head: A): (tail: Array<A>) => NonEmptyArray<A>
export declare function cons<A>(head: A, tail: Array<A>): NonEmptyArray<A>

Added in v2.0.0 v2.0.0 中添加

filterWithIndex 带索引的过滤器

Use filterWithIndex instead. 请改用 filterWithIndex

Signature 签名

export declare const filterWithIndex: <A>(
  predicate: (i: number, a: A) => boolean
) => (as: NonEmptyArray<A>) => Option<NonEmptyArray<A>>

Added in v2.0.0 v2.0.0 中添加

filter 筛选

Use filter instead. 请改用 filter

Signature 签名

export declare function filter<A, B extends A>(
  refinement: Refinement<A, B>
): (as: NonEmptyArray<A>) => Option<NonEmptyArray<B>>
export declare function filter<A>(
  predicate: Predicate<A>
): <B extends A>(bs: NonEmptyArray<B>) => Option<NonEmptyArray<B>>
export declare function filter<A>(predicate: Predicate<A>): (as: NonEmptyArray<A>) => Option<NonEmptyArray<A>>

Added in v2.0.0 v2.0.0 中添加

fold 折叠

Use concatAll instead. 请改用 concatAll

Signature 签名

export declare const fold: <A>(S: Se.Semigroup<A>) => (fa: NonEmptyArray<A>) => A

Added in v2.5.0 v2.5.0中添加

groupSort 分组排序

This is just sort followed by group.
这只是 sort 后面跟着 group

Signature 签名

export declare function groupSort<B>(O: Ord<B>): {
  <A extends B>(as: NonEmptyArray<A>): NonEmptyArray<NonEmptyArray<A>>
  <A extends B>(as: Array<A>): Array<NonEmptyArray<A>>
}

Added in v2.0.0 v2.0.0 中添加

nonEmptyArray 非空数组

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass NEA.Functor instead of NEA.nonEmptyArray (where NEA is from import NEA from 'fp-ts/NonEmptyArray')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 NEA.Functor 而不是 NEA.nonEmptyArray (其中 NEA 来自 import NEA from 'fp-ts/NonEmptyArray'

Signature 签名

export declare const nonEmptyArray: Monad1<'NonEmptyArray'> &
  Comonad1<'NonEmptyArray'> &
  TraversableWithIndex1<'NonEmptyArray', number> &
  FunctorWithIndex1<'NonEmptyArray', number> &
  FoldableWithIndex1<'NonEmptyArray', number> &
  Alt1<'NonEmptyArray'>

Added in v2.0.0 v2.0.0 中添加

prependToAll 前置到全部

Use prependAll instead. 请改用 prependAll

Signature 签名

export declare const prependToAll: <A>(middle: A) => (as: NonEmptyArray<A>) => NonEmptyArray<A>

Added in v2.9.0 v2.9.0中添加

snoc 斯诺克

Use append instead. 请改用 append

Signature 签名

export declare const snoc: <A>(init: A[], end: A) => NonEmptyArray<A>

Added in v2.0.0 v2.0.0 中添加

uncons 不合理

Use unprepend instead. 请改用 unprepend

Signature 签名

export declare const uncons: <A>(as: NonEmptyArray<A>) => [A, A[]]

Added in v2.9.0 v2.9.0中添加

unsnoc 联合国国家奥委会

Use unappend instead. 请改用 unappend

Signature 签名

export declare const unsnoc: <A>(as: NonEmptyArray<A>) => [A[], A]

Added in v2.9.0 v2.9.0中添加

number overview  号码概览

Added in v2.10.0 v2.10.0 中添加


Table of contents
目录


instances   实例

Bounded   有界

Signature 签名

export declare const Bounded: B.Bounded<number>

Added in v2.10.0 v2.10.0 中添加

Eq   方程

Signature 签名

export declare const Eq: E.Eq<number>

Added in v2.10.0 v2.10.0 中添加

Field   场地

Signature 签名

export declare const Field: F.Field<number>

Added in v2.10.0 v2.10.0 中添加

MagmaSub   岩浆潜艇

Signature 签名

export declare const MagmaSub: Magma<number>

Added in v2.11.0 v2.11.0 中添加

MonoidProduct   幺半群积

number monoid under multiplication.
number 乘法下的幺半群。

The empty value is 1.
empty 值为 1

Signature 签名

export declare const MonoidProduct: Monoid<number>

Example 例子

import { MonoidProduct } from 'fp-ts/number'

assert.deepStrictEqual(MonoidProduct.concat(2, MonoidProduct.empty), 2)

Added in v2.10.0 v2.10.0 中添加

MonoidSum   幺半群和

number monoid under addition.
number 幺半群在加法下。

The empty value is 0.
empty 值为 0

Signature 签名

export declare const MonoidSum: Monoid<number>

Example 例子

import { MonoidSum } from 'fp-ts/number'

assert.deepStrictEqual(MonoidSum.concat(2, MonoidSum.empty), 2)

Added in v2.10.0 v2.10.0 中添加

Ord   奥德

Signature 签名

export declare const Ord: O.Ord<number>

Added in v2.10.0 v2.10.0 中添加

SemigroupProduct   半群产品

number semigroup under multiplication.
number 乘法下的半群。

Signature 签名

export declare const SemigroupProduct: Semigroup<number>

Example 例子

import { SemigroupProduct } from 'fp-ts/number'

assert.deepStrictEqual(SemigroupProduct.concat(2, 3), 6)

Added in v2.10.0 v2.10.0 中添加

SemigroupSum   半群和

number semigroup under addition.
number 加法下的半群。

Signature 签名

export declare const SemigroupSum: Semigroup<number>

Example 例子

import { SemigroupSum } from 'fp-ts/number'

assert.deepStrictEqual(SemigroupSum.concat(2, 3), 5)

Added in v2.10.0 v2.10.0 中添加

Show   展示

Signature 签名

export declare const Show: S.Show<number>

Added in v2.10.0 v2.10.0 中添加

refinements   改进

isNumber   是编号

Signature 签名

export declare const isNumber: Refinement<unknown, number>

Added in v2.11.0 v2.11.0 中添加

Option overview  选项概述

type Option<A> = None | Some<A>

Option<A> is a container for an optional value of type A. If the value of type A is present, the Option<A> is an instance of Some<A>, containing the present value of type A. If the value is absent, the Option<A> is an instance of None.
Option<A>A 类型的可选值的容器。如果存在 A 类型的值,则 Option<A>Some<A> 的实例,包含 A 类型的当前值。如果该值不存在,则 Option<A>None 的实例。

An option could be looked at as a collection or foldable structure with either one or zero elements. Another way to look at Option is: it represents the effect of a possibly failing computation.
选项可以被视为具有一个或零个元素的集合或可折叠结构。另一种看待 Option 的方式是:它表示可能失败的计算的影响。

Example 例子

import * as O from 'fp-ts/Option'
import { pipe } from 'fp-ts/function'

const double = (n: number): number => n * 2

export const imperative = (as: ReadonlyArray<number>): string => {
  const head = (as: ReadonlyArray<number>): number => {
    if (as.length === 0) {
      throw new Error()
    }
    return as[0]
  }
  const inverse = (n: number): number => {
    if (n === 0) {
      throw new Error()
    }
    return 1 / n
  }
  try {
    return `Result is ${inverse(double(head(as)))}`
  } catch (e) {
    return 'no result'
  }
}

export const functional = (as: ReadonlyArray<number>): string => {
  const head = <A>(as: ReadonlyArray<A>): O.Option<A> => (as.length === 0 ? O.none : O.some(as[0]))
  const inverse = (n: number): O.Option<number> => (n === 0 ? O.none : O.some(1 / n))
  return pipe(
    as,
    head,
    O.map(double),
    O.flatMap(inverse),
    O.match(
      () => 'no result', // onNone handler
      (head) => `Result is ${head}` // onSome handler
    )
  )
}

assert.deepStrictEqual(imperative([1, 2, 3]), functional([1, 2, 3]))
assert.deepStrictEqual(imperative([]), functional([]))
assert.deepStrictEqual(imperative([0]), functional([0]))

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


combinators   组合器

tap   轻敲

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tap: {
  <A, _>(self: Option<A>, f: (a: A) => Option<_>): Option<A>
  <A, _>(f: (a: A) => Option<_>): (self: Option<A>) => Option<A>
}

Added in v2.15.0 v2.15.0 中添加

tapEither   点击任一

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapEither: {
  <A, E, _>(f: (a: A) => Either<E, _>): (self: Option<A>) => Option<A>
  <A, E, _>(self: Option<A>, f: (a: A) => Either<E, _>): Option<A>
}

Example 例子

import { pipe } from 'fp-ts/function'
import * as O from 'fp-ts/Option'
import * as E from 'fp-ts/Either'

const compute = (value: number) =>
  pipe(
    O.of(value),
    O.tapEither((value) => (value > 0 ? E.right('ok') : E.left('error')))
  )

assert.deepStrictEqual(compute(1), O.of(1))
assert.deepStrictEqual(compute(-42), O.none)

Added in v2.16.0 v2.16.0 中添加

constructors  构造函数

getLeft   向左

Returns the Left value of an Either if possible.
如果可能,返回 EitherLeft 值。

Signature 签名

export declare const getLeft: <E, A>(ma: Either<E, A>) => Option<E>

Example 例子

import { getLeft, none, some } from 'fp-ts/Option'
import { right, left } from 'fp-ts/Either'

assert.deepStrictEqual(getLeft(right(1)), none)
assert.deepStrictEqual(getLeft(left('a')), some('a'))

Added in v2.0.0 v2.0.0 中添加

getRight   得到正确的

Returns the Right value of an Either if possible.
如果可能,返回 EitherRight 值。

Signature 签名

export declare const getRight: <E, A>(ma: Either<E, A>) => Option<A>

Example 例子

import { getRight, none, some } from 'fp-ts/Option'
import { right, left } from 'fp-ts/Either'

assert.deepStrictEqual(getRight(right(1)), some(1))
assert.deepStrictEqual(getRight(left('a')), none)

Added in v2.0.0 v2.0.0 中添加

none   没有任何

None doesn’t have a constructor, instead you can use it directly as a value. Represents a missing value.
None 没有构造函数,您可以直接将其用作值。代表缺失值。

Signature 签名

export declare const none: Option<never>

Added in v2.0.0 v2.0.0 中添加

of  

Signature 签名

export declare const of: <A>(a: A) => Option<A>

Added in v2.7.0 v2.7.0 中添加

some   一些

Constructs a Some. Represents an optional value that exists.
构造一个 Some 。表示存在的可选值。

Signature 签名

export declare const some: <A>(a: A) => Option<A>

Added in v2.0.0 v2.0.0 中添加

conversions   转换

fromEither   来自任一

Transforms an Either to an Option discarding the error.
Either 转换为 Option 并丢弃错误。

Alias of getRight getRight 的别名

Signature 签名

export declare const fromEither: <A>(fa: Either<unknown, A>) => Option<A>

Added in v2.0.0 v2.0.0 中添加

fromNullable   来自可为空的

Constructs a new Option from a nullable type. If the value is null or undefined, returns None, otherwise returns the value wrapped in a Some.
从可为 null 的类型构造一个新的 Option 。如果值为 nullundefined ,则返回 None ,否则返回用 Some 包装的值。

Signature 签名

export declare const fromNullable: <A>(a: A) => Option<NonNullable<A>>

Example 例子

import { none, some, fromNullable } from 'fp-ts/Option'

assert.deepStrictEqual(fromNullable(undefined), none)
assert.deepStrictEqual(fromNullable(null), none)
assert.deepStrictEqual(fromNullable(1), some(1))

Added in v2.0.0 v2.0.0 中添加

toNullable   为可空

Extracts the value out of the structure, if it exists. Otherwise returns null.
从结构中提取值(如果存在)。否则返回 null

Signature 签名

export declare const toNullable: <A>(ma: Option<A>) => A | null

Example 例子

import { some, none, toNullable } from 'fp-ts/Option'
import { pipe } from 'fp-ts/function'

assert.strictEqual(pipe(some(1), toNullable), 1)
assert.strictEqual(pipe(none, toNullable), null)

Added in v2.0.0 v2.0.0 中添加

toUndefined   未定义

Extracts the value out of the structure, if it exists. Otherwise returns undefined.
从结构中提取值(如果存在)。否则返回 undefined

Signature 签名

export declare const toUndefined: <A>(ma: Option<A>) => A | undefined

Example 例子

import { some, none, toUndefined } from 'fp-ts/Option'
import { pipe } from 'fp-ts/function'

assert.strictEqual(pipe(some(1), toUndefined), 1)
assert.strictEqual(pipe(none, toUndefined), undefined)

Added in v2.0.0 v2.0.0 中添加

do notation   做记号

Do  

Signature 签名

export declare const Do: Option<{}>

Added in v2.9.0 v2.9.0中添加

apS   apS

Signature 签名

export declare const apS: <N, A, B>(
  name: Exclude<N, keyof A>,
  fb: Option<B>
) => (fa: Option<A>) => Option<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bind   绑定

Signature 签名

export declare const bind: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => Option<B>
) => (ma: Option<A>) => Option<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bindTo   绑定到

Signature 签名

export declare const bindTo: <N>(name: N) => <A>(fa: Option<A>) => Option<{ readonly [K in N]: A }>

Added in v2.8.0 v2.8.0 中添加

guard   警卫

Signature 签名

export declare const guard: (b: boolean) => Option<void>

Added in v2.11.0 v2.11.0 中添加

let  

Signature 签名

export declare const let: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => (fa: Option<A>) => Option<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.13.0 v2.13.0 中添加

error handling   错误处理

getOrElse  获取或否则

Extracts the value out of the structure, if it exists. Otherwise returns the given default value
从结构中提取值(如果存在)。否则返回给定的默认值

Signature 签名

export declare const getOrElse: <A>(onNone: LazyArg<A>) => (ma: Option<A>) => A

Example 例子

import { some, none, getOrElse } from 'fp-ts/Option'
import { pipe } from 'fp-ts/function'

assert.strictEqual(
  pipe(
    some(1),
    getOrElse(() => 0)
  ),
  1
)
assert.strictEqual(
  pipe(
    none,
    getOrElse(() => 0)
  ),
  0
)

Added in v2.0.0 v2.0.0 中添加

getOrElseW   获取或否则W

Less strict version of getOrElse.
getOrElse 的不太严格版本。

The W suffix (short for Widening) means that the handler return type will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const getOrElseW: <B>(onNone: LazyArg<B>) => <A>(ma: Option<A>) => B | A

Added in v2.6.0 v2.6.0 中添加

orElse   要不然

Returns the provided Option that if self is None, otherwise returns self.
如果 selfNone ,则返回提供的 Option that ,否则返回 self

Signature 签名

export declare const orElse: {
  <B>(that: LazyArg<Option<B>>): <A>(self: Option<A>) => Option<B | A>
  <A, B>(self: Option<A>, that: LazyArg<Option<B>>): Option<A | B>
}

Example 例子

import * as O from 'fp-ts/Option'

assert.deepStrictEqual(
  O.orElse(O.none, () => O.none),
  O.none
)
assert.deepStrictEqual(
  O.orElse(O.some(1), () => O.none),
  O.some(1)
)
assert.deepStrictEqual(
  O.orElse(O.none, () => O.some('b')),
  O.some('b')
)
assert.deepStrictEqual(
  O.orElse(O.some(1), () => O.some('b')),
  O.some(1)
)

Added in v2.16.0 v2.16.0 中添加

filtering   过滤

compact   袖珍的

Signature 签名

export declare const compact: <A>(fa: Option<Option<A>>) => Option<A>

Added in v2.0.0 v2.0.0 中添加

filter   筛选

Signature 签名

export declare const filter: {
  <A, B extends A>(refinement: Refinement<A, B>): (fa: Option<A>) => Option<B>
  <A>(predicate: Predicate<A>): <B extends A>(fb: Option<B>) => Option<B>
  <A>(predicate: Predicate<A>): (fa: Option<A>) => Option<A>
}

Added in v2.0.0 v2.0.0 中添加

filterMap   过滤映射

Signature 签名

export declare const filterMap: <A, B>(f: (a: A) => Option<B>) => (fa: Option<A>) => Option<B>

Added in v2.0.0 v2.0.0 中添加

partition   分割

Signature 签名

export declare const partition: {
  <A, B extends A>(refinement: Refinement<A, B>): (fa: Option<A>) => Separated<Option<A>, Option<B>>
  <A>(predicate: Predicate<A>): <B extends A>(fb: Option<B>) => Separated<Option<B>, Option<B>>
  <A>(predicate: Predicate<A>): (fa: Option<A>) => Separated<Option<A>, Option<A>>
}

Added in v2.0.0 v2.0.0 中添加

partitionMap   分区图

Signature 签名

export declare const partitionMap: <A, B, C>(
  f: (a: A) => Either<B, C>
) => (fa: Option<A>) => Separated<Option<B>, Option<C>>

Added in v2.0.0 v2.0.0 中添加

separate   分离

Signature 签名

export declare const separate: <A, B>(ma: Option<Either<A, B>>) => Separated<Option<A>, Option<B>>

Added in v2.0.0 v2.0.0 中添加

wilt   枯萎

Signature 签名

export declare const wilt: PipeableWilt1<'Option'>

Added in v2.6.5 v2.6.5 中添加

wither   枯萎

Signature 签名

export declare const wither: PipeableWither1<'Option'>

Added in v2.6.5 v2.6.5 中添加

folding   折叠式的

foldMap   折叠图

Signature 签名

export declare const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: Option<A>) => M

Added in v2.0.0 v2.0.0 中添加

reduce   减少

Signature 签名

export declare const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: Option<A>) => B

Added in v2.0.0 v2.0.0 中添加

reduceRight   减少右

Signature 签名

export declare const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: Option<A>) => B

Added in v2.0.0 v2.0.0 中添加

instances   实例

Alt   替代

Signature 签名

export declare const Alt: Alt1<'Option'>

Added in v2.7.0 v2.7.0 中添加

Alternative   选择

Signature 签名

export declare const Alternative: Alternative1<'Option'>

Added in v2.7.0 v2.7.0 中添加

Applicative   适用性

Signature 签名

export declare const Applicative: Applicative1<'Option'>

Added in v2.7.0 v2.7.0 中添加

Apply   申请

Signature 签名

export declare const Apply: Apply1<'Option'>

Added in v2.10.0 v2.10.0 中添加

Chain  

Signature 签名

export declare const Chain: chainable.Chain1<'Option'>

Added in v2.10.0 v2.10.0 中添加

Compactable   紧凑型

Signature 签名

export declare const Compactable: Compactable1<'Option'>

Added in v2.7.0 v2.7.0 中添加

Extend   延长

Signature 签名

export declare const Extend: Extend1<'Option'>

Added in v2.7.0 v2.7.0 中添加

Filterable   可过滤

Signature 签名

export declare const Filterable: Filterable1<'Option'>

Added in v2.7.0 v2.7.0 中添加

Foldable   折叠式

Signature 签名

export declare const Foldable: Foldable1<'Option'>

Added in v2.7.0 v2.7.0 中添加

FromEither   来自任一

Signature 签名

export declare const FromEither: FromEither1<'Option'>

Added in v2.11.0 v2.11.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor1<'Option'>

Added in v2.7.0 v2.7.0 中添加

Monad   单子

Signature 签名

export declare const Monad: Monad1<'Option'>

Added in v2.7.0 v2.7.0 中添加

MonadThrow   单子投掷

Signature 签名

export declare const MonadThrow: MonadThrow1<'Option'>

Added in v2.7.0 v2.7.0 中添加

Pointed  

Signature 签名

export declare const Pointed: Pointed1<'Option'>

Added in v2.10.0 v2.10.0 中添加

Traversable   可穿越

Signature 签名

export declare const Traversable: Traversable1<'Option'>

Added in v2.7.0 v2.7.0 中添加

Witherable   枯萎的

Signature 签名

export declare const Witherable: Witherable1<'Option'>

Added in v2.7.0 v2.7.0 中添加

Zero  

Signature 签名

export declare const Zero: Zero1<'Option'>

Added in v2.11.0 v2.11.0 中添加

getEq   得到方程

Signature 签名

export declare const getEq: <A>(E: Eq<A>) => Eq<Option<A>>

Example 例子

import { none, some, getEq } from 'fp-ts/Option'
import * as N from 'fp-ts/number'

const E = getEq(N.Eq)
assert.strictEqual(E.equals(none, none), true)
assert.strictEqual(E.equals(none, some(1)), false)
assert.strictEqual(E.equals(some(1), none), false)
assert.strictEqual(E.equals(some(1), some(2)), false)
assert.strictEqual(E.equals(some(1), some(1)), true)

Added in v2.0.0 v2.0.0 中添加

getMonoid   获取Monoid

Monoid returning the left-most non-None value. If both operands are Somes then the inner values are concatenated using the provided Semigroup
Monoid 返回最左边的非 None 值。如果两个操作数都是 Some s,则使用提供的 Semigroup 连接内部值

x X y y concat(x, y) 连接(x,y)
none 没有任何 none 没有任何 none 没有任何
some(a) 一些(一) none 没有任何 some(a) 一些(一)
none 没有任何 some(b) 一些(b) some(b) 一些(b)
some(a) 一些(一) some(b) 一些(b) some(concat(a, b)) 一些(连接(a,b))

Signature 签名

export declare const getMonoid: <A>(S: Semigroup<A>) => Monoid<Option<A>>

Example 例子

import { getMonoid, some, none } from 'fp-ts/Option'
import { SemigroupSum } from 'fp-ts/number'

const M = getMonoid(SemigroupSum)
assert.deepStrictEqual(M.concat(none, none), none)
assert.deepStrictEqual(M.concat(some(1), none), some(1))
assert.deepStrictEqual(M.concat(none, some(1)), some(1))
assert.deepStrictEqual(M.concat(some(1), some(2)), some(3))

Added in v2.0.0 v2.0.0 中添加

getOrd   获取订单

The Ord instance allows Option values to be compared with compare, whenever there is an Ord instance for the type the Option contains.
只要 Option 包含的类型存在 Ord 实例, Ord 实例就允许将 Option 值与 compare 进行比较。

None is considered to be less than any Some value.
None 被认为小于任何 Some 值。

Signature 签名

export declare const getOrd: <A>(O: Ord<A>) => Ord<Option<A>>

Example 例子

import { none, some, getOrd } from 'fp-ts/Option'
import * as N from 'fp-ts/number'

const O = getOrd(N.Ord)
assert.strictEqual(O.compare(none, none), 0)
assert.strictEqual(O.compare(none, some(1)), -1)
assert.strictEqual(O.compare(some(1), none), 1)
assert.strictEqual(O.compare(some(1), some(2)), -1)
assert.strictEqual(O.compare(some(1), some(1)), 0)

Added in v2.0.0 v2.0.0 中添加

getShow   获取显示

Signature 签名

export declare const getShow: <A>(S: Show<A>) => Show<Option<A>>

Added in v2.0.0 v2.0.0 中添加

interop   互操作

tryCatch   试着抓

Transforms an exception into an Option. If f throws, returns None, otherwise returns the output wrapped in a Some.
将异常转换为 Option 。如果 f 抛出,则返回 None ,否则返回包装在 Some 中的输出。

See also tryCatchK. 另请参阅 tryCatchK

Signature 签名

export declare const tryCatch: <A>(f: LazyArg<A>) => Option<A>

Example 例子

import { none, some, tryCatch } from 'fp-ts/Option'

assert.deepStrictEqual(
  tryCatch(() => {
    throw new Error()
  }),
  none
)
assert.deepStrictEqual(
  tryCatch(() => 1),
  some(1)
)

Added in v2.0.0 v2.0.0 中添加

tryCatchK   尝试捕获K

Converts a function that may throw to one returning a Option.
将可能抛出异常的函数转换为返回 Option 的函数。

Signature 签名

export declare const tryCatchK: <A extends readonly unknown[], B>(f: (...a: A) => B) => (...a: A) => Option<B>

Added in v2.10.0 v2.10.0 中添加

legacy   遗产

alt   替代

Alias of orElse.  orElse 的别名。

Signature 签名

export declare const alt: <A>(that: LazyArg<Option<A>>) => (fa: Option<A>) => Option<A>

Added in v2.0.0 v2.0.0 中添加

altW   替代W

Alias of orElse.  orElse 的别名。

Less strict version of alt.
alt 的不太严格版本。

The W suffix (short for Widening) means that the return types will be merged.
W 后缀(Widening 的缩写)意味着返回类型将被合并。

Signature 签名

export declare const altW: <B>(that: LazyArg<Option<B>>) => <A>(fa: Option<A>) => Option<B | A>

Added in v2.9.0 v2.9.0中添加

chain  

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chain: <A, B>(f: (a: A) => Option<B>) => (ma: Option<A>) => Option<B>

Added in v2.0.0 v2.0.0 中添加

chainFirst   链优先

Alias of tap.  tap 的别名。

Signature 签名

export declare const chainFirst: <A, B>(f: (a: A) => Option<B>) => (first: Option<A>) => Option<A>

Added in v2.0.0 v2.0.0 中添加

chainFirstEitherK  链FirstEiK

Alias of tapEither.  tapEither 的别名。

Signature 签名

export declare const chainFirstEitherK: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: Option<A>) => Option<A>

Added in v2.12.0 v2.12.0 中添加

lifting   起重

fromEitherK   来自EitherK

Signature 签名

export declare const fromEitherK: <E, A extends readonly unknown[], B>(
  f: (...a: A) => Either<E, B>
) => (...a: A) => Option<B>

Added in v2.11.0 v2.11.0 中添加

fromNullableK  来自可空K

Returns a smart constructor from a function that returns a nullable value.
从返回可为空值的函数返回智能构造函数。

Signature 签名

export declare const fromNullableK: <A extends readonly unknown[], B>(
  f: (...a: A) => B | null | undefined
) => (...a: A) => Option<NonNullable<B>>

Example 例子

import { fromNullableK, none, some } from 'fp-ts/Option'

const f = (s: string): number | undefined => {
  const n = parseFloat(s)
  return isNaN(n) ? undefined : n
}

const g = fromNullableK(f)

assert.deepStrictEqual(g('1'), some(1))
assert.deepStrictEqual(g('a'), none)

Added in v2.9.0 v2.9.0中添加

fromPredicate   来自谓词

Returns a smart constructor based on the given predicate.
返回基于给定谓词的智能构造函数。

Signature 签名

export declare function fromPredicate<A, B extends A>(refinement: Refinement<A, B>): (a: A) => Option<B>
export declare function fromPredicate<A>(predicate: Predicate<A>): <B extends A>(b: B) => Option<B>
export declare function fromPredicate<A>(predicate: Predicate<A>): (a: A) => Option<A>

Example 例子

import { none, some, fromPredicate } from 'fp-ts/Option'

const getOption = fromPredicate((n: number) => n >= 0)

assert.deepStrictEqual(getOption(-1), none)
assert.deepStrictEqual(getOption(1), some(1))

Added in v2.0.0 v2.0.0 中添加

mapping   映射

as   作为

Maps the Some value of this Option to the specified constant value.
将此 OptionSome 值映射到指定的常量值。

Signature 签名

export declare const as: { <A>(a: A): <_>(self: Option<_>) => Option<A>; <_, A>(self: Option<_>, a: A): Option<A> }

Added in v2.16.0 v2.16.0 中添加

asUnit   作为单位

Maps the Some value of this Option to the void constant value.
将此 OptionSome 值映射到void 常量值。

Signature 签名

export declare const asUnit: <_>(self: Option<_>) => Option<void>

Added in v2.16.0 v2.16.0 中添加

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <B>(fab: Option<(a: A) => B>) => Option<B>

Added in v2.10.0 v2.10.0 中添加

map   地图

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => (fa: Option<A>) => Option<B>

Added in v2.0.0 v2.0.0 中添加

model   模型

None (interface)   无(接口)

Signature 签名

export interface None {
  readonly _tag: 'None'
}

Added in v2.0.0 v2.0.0 中添加

Option (type alias)
选项(类型别名)

Signature 签名

export type Option<A> = None | Some<A>

Added in v2.0.0 v2.0.0 中添加

Some (interface)   一些(界面)

Signature 签名

export interface Some<A> {
  readonly _tag: 'Some'
  readonly value: A
}

Added in v2.0.0 v2.0.0 中添加

pattern matching   模式匹配

fold   折叠

Alias of match.  match 的别名。

Signature 签名

export declare const fold: <A, B>(onNone: LazyArg<B>, onSome: (a: A) => B) => (ma: Option<A>) => B

Added in v2.0.0 v2.0.0 中添加

foldW   折叠W

Alias of matchW.  matchW 的别名。

Signature 签名

export declare const foldW: <B, A, C>(onNone: LazyArg<B>, onSome: (a: A) => C) => (ma: Option<A>) => B | C

Added in v2.10.0 v2.10.0 中添加

match   匹配

Takes a (lazy) default value, a function, and an Option value, if the Option value is None the default value is returned, otherwise the function is applied to the value inside the Some and the result is returned.
接受一个(惰性)默认值、一个函数和一个 Option 值,如果 Option 值是 None 则返回默认值,否则函数将应用于 Some 内的值和结果被返回。

Signature 签名

export declare const match: <A, B>(onNone: LazyArg<B>, onSome: (a: A) => B) => (ma: Option<A>) => B

Example 例子

import { some, none, match } from 'fp-ts/Option'
import { pipe } from 'fp-ts/function'

assert.strictEqual(
  pipe(
    some(1),
    match(
      () => 'a none',
      (a) => `a some containing ${a}`
    )
  ),
  'a some containing 1'
)

assert.strictEqual(
  pipe(
    none,
    match(
      () => 'a none',
      (a) => `a some containing ${a}`
    )
  ),
  'a none'
)

Added in v2.10.0 v2.10.0 中添加

matchW   匹配W

Less strict version of match.
match 的不太严格版本。

The W suffix (short for Widening) means that the handler return types will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const matchW: <B, A, C>(onNone: LazyArg<B>, onSome: (a: A) => C) => (ma: Option<A>) => B | C

Added in v2.10.0 v2.10.0 中添加

refinements   改进

isNone   没有

Returns true if the option is None, false otherwise.
如果选项是 None ,则返回 true ,否则返回 false

Signature 签名

export declare const isNone: (fa: Option<unknown>) => fa is None

Example 例子

import { some, none, isNone } from 'fp-ts/Option'

assert.strictEqual(isNone(some(1)), false)
assert.strictEqual(isNone(none), true)

Added in v2.0.0 v2.0.0 中添加

isSome   是一些

Returns true if the option is an instance of Some, false otherwise.
如果选项是 Some 的实例,则返回 true ,否则返回 false

Signature 签名

export declare const isSome: <A>(fa: Option<A>) => fa is Some<A>

Example 例子

import { some, none, isSome } from 'fp-ts/Option'

assert.strictEqual(isSome(some(1)), true)
assert.strictEqual(isSome(none), false)

Added in v2.0.0 v2.0.0 中添加

sequencing   测序

chainEitherK  链EiK

Signature 签名

export declare const chainEitherK: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: Option<A>) => Option<B>

Added in v2.11.0 v2.11.0 中添加

chainNullableK   链可空K

This is chain + fromNullable, useful when working with optional values.
这是 chain + fromNullable ,在使用可选值时很有用。

Signature 签名

export declare const chainNullableK: <A, B>(
  f: (a: A) => B | null | undefined
) => (ma: Option<A>) => Option<NonNullable<B>>

Example 例子

import { some, none, fromNullable, chainNullableK } from 'fp-ts/Option'
import { pipe } from 'fp-ts/function'

interface Employee {
  readonly company?: {
    readonly address?: {
      readonly street?: {
        readonly name?: string
      }
    }
  }
}

const employee1: Employee = { company: { address: { street: { name: 'high street' } } } }

assert.deepStrictEqual(
  pipe(
    fromNullable(employee1.company),
    chainNullableK((company) => company.address),
    chainNullableK((address) => address.street),
    chainNullableK((street) => street.name)
  ),
  some('high street')
)

const employee2: Employee = { company: { address: { street: {} } } }

assert.deepStrictEqual(
  pipe(
    fromNullable(employee2.company),
    chainNullableK((company) => company.address),
    chainNullableK((address) => address.street),
    chainNullableK((street) => street.name)
  ),
  none
)

Added in v2.9.0 v2.9.0中添加

flatMap   平面地图

Signature 签名

export declare const flatMap: {
  <A, B>(f: (a: A) => Option<B>): (ma: Option<A>) => Option<B>
  <A, B>(ma: Option<A>, f: (a: A) => Option<B>): Option<B>
}

Added in v2.14.0 v2.14.0 中添加

flatten   压扁

Signature 签名

export declare const flatten: <A>(mma: Option<Option<A>>) => Option<A>

Added in v2.0.0 v2.0.0 中添加

traversing   穿越

sequence   顺序

Signature 签名

export declare const sequence: Sequence1<'Option'>

Added in v2.6.3 v2.6.3 中添加

sequenceArray   序列数组

Equivalent to ReadonlyArray#sequence(Applicative). 相当于 ReadonlyArray#sequence(Applicative)

Signature 签名

export declare const sequenceArray: <A>(arr: readonly Option<A>[]) => Option<readonly A[]>

Added in v2.9.0 v2.9.0中添加

traverse   遍历

Signature 签名

export declare const traverse: PipeableTraverse1<'Option'>

Added in v2.6.3 v2.6.3 中添加

traverseArray   遍历数组

Equivalent to ReadonlyArray#traverse(Applicative). 相当于 ReadonlyArray#traverse(Applicative)

Signature 签名

export declare const traverseArray: <A, B>(f: (a: A) => Option<B>) => (as: readonly A[]) => Option<readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseArrayWithIndex   带索引遍历数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseArrayWithIndex: <A, B>(
  f: (index: number, a: A) => Option<B>
) => (as: readonly A[]) => Option<readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseReadonlyArrayWithIndex
遍历带索引的只读数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseReadonlyArrayWithIndex: <A, B>(
  f: (index: number, a: A) => Option<B>
) => (as: readonly A[]) => Option<readonly B[]>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyNonEmptyArrayWithIndex
遍历ReadonlyNonEmptyArrayWithIndex

Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(Applicative). 相当于 ReadonlyNonEmptyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseReadonlyNonEmptyArrayWithIndex: <A, B>(
  f: (index: number, a: A) => Option<B>
) => (as: ReadonlyNonEmptyArray<A>) => Option<ReadonlyNonEmptyArray<B>>

Added in v2.11.0 v2.11.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'Option'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

ApT   易于

Signature 签名

export declare const ApT: Option<readonly []>

Added in v2.11.0 v2.11.0 中添加

ap   美联社

Signature 签名

export declare const ap: <A>(fa: Option<A>) => <B>(fab: Option<(a: A) => B>) => Option<B>

Added in v2.0.0 v2.0.0 中添加

apFirst   应用程序第一

Combine two effectful actions, keeping only the result of the first.
结合两个有效的操作,仅保留第一个操作的结果。

Signature 签名

export declare const apFirst: <B>(second: Option<B>) => <A>(first: Option<A>) => Option<A>

Added in v2.0.0 v2.0.0 中添加

apSecond   ap秒

Combine two effectful actions, keeping only the result of the second.
结合两个有效的操作,只保留第二个的结果。

Signature 签名

export declare const apSecond: <B>(second: Option<B>) => <A>(first: Option<A>) => Option<B>

Added in v2.0.0 v2.0.0 中添加

duplicate   复制

Signature 签名

export declare const duplicate: <A>(ma: Option<A>) => Option<Option<A>>

Added in v2.0.0 v2.0.0 中添加

elem   埃莱姆

Returns true if ma contains a
如果 ma 包含 a ,则返回 true

Signature 签名

export declare function elem<A>(E: Eq<A>): {
  (a: A): (ma: Option<A>) => boolean
  (a: A, ma: Option<A>): boolean
}

Example 例子

import { some, none, elem } from 'fp-ts/Option'
import { pipe } from 'fp-ts/function'
import * as N from 'fp-ts/number'

assert.strictEqual(pipe(some(1), elem(N.Eq)(1)), true)
assert.strictEqual(pipe(some(1), elem(N.Eq)(2)), false)
assert.strictEqual(pipe(none, elem(N.Eq)(1)), false)

Added in v2.0.0 v2.0.0 中添加

exists   存在

Returns true if the predicate is satisfied by the wrapped value
如果包装值满足谓词,则返回 true

Signature 签名

export declare const exists: <A>(predicate: Predicate<A>) => (ma: Option<A>) => boolean

Example 例子

import { some, none, exists } from 'fp-ts/Option'
import { pipe } from 'fp-ts/function'

assert.strictEqual(
  pipe(
    some(1),
    exists((n) => n > 0)
  ),
  true
)
assert.strictEqual(
  pipe(
    some(1),
    exists((n) => n > 1)
  ),
  false
)
assert.strictEqual(
  pipe(
    none,
    exists((n) => n > 0)
  ),
  false
)

Added in v2.0.0 v2.0.0 中添加

extend   延长

Signature 签名

export declare const extend: <A, B>(f: (wa: Option<A>) => B) => (wa: Option<A>) => Option<B>

Added in v2.0.0 v2.0.0 中添加

throwError   抛出错误

Signature 签名

export declare const throwError: <E, A>(e: E) => Option<A>

Added in v2.7.0 v2.7.0 中添加

zero  

Signature 签名

export declare const zero: <A>() => Option<A>

Added in v2.7.0 v2.7.0 中添加

zone of death
死亡地带

getApplyMonoid 获取应用Monoid

Use getApplicativeMonoid instead. 请改用 getApplicativeMonoid

Signature 签名

export declare const getApplyMonoid: <A>(M: Monoid<A>) => Monoid<Option<A>>

Added in v2.0.0 v2.0.0 中添加

getApplySemigroup 获取ApplySemigroup

Use getApplySemigroup instead. 请改用 getApplySemigroup

Signature 签名

export declare const getApplySemigroup: <A>(S: Semigroup<A>) => Semigroup<Option<A>>

Added in v2.0.0 v2.0.0 中添加

getFirstMonoid 获取第一个Monoid

Use 使用

import { first } from 'fp-ts/Semigroup'
import { getMonoid } from 'fp-ts/Option'

getMonoid(first())

instead.

Monoid returning the left-most non-None value
Monoid 返回最左边的非 None

x X y y concat(x, y) 连接(x,y)
none 没有任何 none 没有任何 none 没有任何
some(a) 一些(一) none 没有任何 some(a) 一些(一)
none 没有任何 some(b) 一些(b) some(b) 一些(b)
some(a) 一些(一) some(b) 一些(b) some(a) 一些(一)

Signature 签名

export declare const getFirstMonoid: <A = never>() => Monoid<Option<A>>

Example 例子

import { getFirstMonoid, some, none } from 'fp-ts/Option'

const M = getFirstMonoid<number>()
assert.deepStrictEqual(M.concat(none, none), none)
assert.deepStrictEqual(M.concat(some(1), none), some(1))
assert.deepStrictEqual(M.concat(none, some(2)), some(2))
assert.deepStrictEqual(M.concat(some(1), some(2)), some(1))

Added in v2.0.0 v2.0.0 中添加

getLastMonoid 获取最后一个Monoid

Use 使用

import { last } from 'fp-ts/Semigroup'
import { getMonoid } from 'fp-ts/Option'

getMonoid(last())

instead.

Monoid returning the right-most non-None value
Monoid 返回最右边的非 None

x X y y concat(x, y) 连接(x,y)
none 没有任何 none 没有任何 none 没有任何
some(a) 一些(一) none 没有任何 some(a) 一些(一)
none 没有任何 some(b) 一些(b) some(b) 一些(b)
some(a) 一些(一) some(b) 一些(b) some(b) 一些(b)

Signature 签名

export declare const getLastMonoid: <A = never>() => Monoid<Option<A>>

Example 例子

import { getLastMonoid, some, none } from 'fp-ts/Option'

const M = getLastMonoid<number>()
assert.deepStrictEqual(M.concat(none, none), none)
assert.deepStrictEqual(M.concat(some(1), none), some(1))
assert.deepStrictEqual(M.concat(none, some(2)), some(2))
assert.deepStrictEqual(M.concat(some(1), some(2)), some(2))

Added in v2.0.0 v2.0.0 中添加

getRefinement 得到细化

Use Refinement module instead. 请改用 Refinement 模块。

Signature 签名

export declare function getRefinement<A, B extends A>(getOption: (a: A) => Option<B>): Refinement<A, B>

Added in v2.0.0 v2.0.0 中添加

mapNullable 映射可为空

Use chainNullableK instead. 请改用 chainNullableK

Signature 签名

export declare const mapNullable: <A, B>(f: (a: A) => B | null | undefined) => (ma: Option<A>) => Option<NonNullable<B>>

Added in v2.0.0 v2.0.0 中添加

option 选项

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass O.Functor instead of O.option (where O is from import O from 'fp-ts/Option')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 O.Functor 而不是 O.option (其中 O 来自 import O from 'fp-ts/Option'

Signature 签名

export declare const option: Monad1<'Option'> &
  Foldable1<'Option'> &
  Alternative1<'Option'> &
  Extend1<'Option'> &
  Witherable1<'Option'> &
  MonadThrow1<'Option'>

Added in v2.0.0 v2.0.0 中添加

OptionT overview  选项T概述

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


lifting   起重

fromPredicate   来自谓词

Signature 签名

export declare function fromPredicate<F extends URIS4>(
  F: Pointed4<F>
): {
  <A, B extends A>(refinement: Refinement<A, B>): <S, R, E>(a: A) => Kind4<F, S, R, E, Option<B>>
  <A>(predicate: Predicate<A>): <S, R, E, B extends A>(b: B) => Kind4<F, S, R, E, Option<B>>
  <A>(predicate: Predicate<A>): <S, R, E>(a: A) => Kind4<F, S, R, E, Option<A>>
}
export declare function fromPredicate<F extends URIS3>(
  F: Pointed3<F>
): {
  <A, B extends A>(refinement: Refinement<A, B>): <R, E>(a: A) => Kind3<F, R, E, Option<B>>
  <A>(predicate: Predicate<A>): <R, E, B extends A>(b: B) => Kind3<F, R, E, Option<B>>
  <A>(predicate: Predicate<A>): <R, E>(a: A) => Kind3<F, R, E, Option<A>>
}
export declare function fromPredicate<F extends URIS3, E>(
  F: Pointed3C<F, E>
): {
  <A, B extends A>(refinement: Refinement<A, B>): <R>(a: A) => Kind3<F, R, E, Option<B>>
  <A>(predicate: Predicate<A>): <R, B extends A>(b: B) => Kind3<F, R, E, Option<B>>
  <A>(predicate: Predicate<A>): <R>(a: A) => Kind3<F, R, E, Option<A>>
}
export declare function fromPredicate<F extends URIS2>(
  F: Pointed2<F>
): {
  <A, B extends A>(refinement: Refinement<A, B>): <E>(a: A) => Kind2<F, E, Option<B>>
  <A>(predicate: Predicate<A>): <E, B extends A>(b: B) => Kind2<F, E, Option<B>>
  <A>(predicate: Predicate<A>): <E>(a: A) => Kind2<F, E, Option<A>>
}
export declare function fromPredicate<F extends URIS2, E>(
  F: Pointed2C<F, E>
): {
  <A, B extends A>(refinement: Refinement<A, B>): (a: A) => Kind2<F, E, Option<B>>
  <A>(predicate: Predicate<A>): <B extends A>(b: B) => Kind2<F, E, Option<B>>
  <A>(predicate: Predicate<A>): (a: A) => Kind2<F, E, Option<A>>
}
export declare function fromPredicate<F extends URIS>(
  F: Pointed1<F>
): {
  <A, B extends A>(refinement: Refinement<A, B>): (a: A) => Kind<F, Option<B>>
  <A>(predicate: Predicate<A>): <B extends A>(b: B) => Kind<F, Option<B>>
  <A>(predicate: Predicate<A>): (a: A) => Kind<F, Option<A>>
}
export declare function fromPredicate<F>(F: Pointed<F>): {
  <A, B extends A>(refinement: Refinement<A, B>): (a: A) => HKT<F, Option<B>>
  <A>(predicate: Predicate<A>): <B extends A>(b: B) => HKT<F, Option<B>>
  <A>(predicate: Predicate<A>): (a: A) => HKT<F, Option<A>>
}

Added in v2.10.0 v2.10.0 中添加

pattern matching   模式匹配

match   匹配

Signature 签名

export declare function match<F extends URIS4>(
  F: Functor4<F>
): <B, A>(onNone: () => B, onSome: (a: A) => B) => <S, R, E>(ma: Kind4<F, S, R, E, Option<A>>) => Kind4<F, S, R, E, B>
export declare function match<F extends URIS3>(
  F: Functor3<F>
): <B, A>(onNone: () => B, onSome: (a: A) => B) => <R, E>(ma: Kind3<F, R, E, Option<A>>) => Kind3<F, R, E, B>
export declare function match<F extends URIS3, E>(
  F: Functor3C<F, E>
): <B, A>(onNone: () => B, onSome: (a: A) => B) => <R>(ma: Kind3<F, R, E, Option<A>>) => Kind3<F, R, E, B>
export declare function match<F extends URIS2>(
  F: Functor2<F>
): <B, A>(onNone: () => B, onSome: (a: A) => B) => <E>(ma: Kind2<F, E, Option<A>>) => Kind2<F, E, B>
export declare function match<F extends URIS2, E>(
  F: Functor2C<F, E>
): <B, A>(onNone: () => B, onSome: (a: A) => B) => (ma: Kind2<F, E, Option<A>>) => Kind2<F, E, B>
export declare function match<F extends URIS>(
  F: Functor1<F>
): <B, A>(onNone: () => B, onSome: (a: A) => B) => (ma: Kind<F, Option<A>>) => Kind<F, B>
export declare function match<F>(
  F: Functor<F>
): <B, A>(onNone: () => B, onSome: (a: A) => B) => (ma: HKT<F, Option<A>>) => HKT<F, B>

Added in v2.10.0 v2.10.0 中添加

utils   实用程序

alt   替代

Signature 签名

export declare function alt<M extends URIS4>(
  M: Monad4<M>
): <S, R, E, A>(
  second: LazyArg<Kind4<M, S, R, E, Option<A>>>
) => (first: Kind4<M, S, R, E, Option<A>>) => Kind4<M, S, R, E, Option<A>>
export declare function alt<M extends URIS3>(
  M: Monad3<M>
): <R, E, A>(
  second: LazyArg<Kind3<M, R, E, Option<A>>>
) => (first: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, Option<A>>
export declare function alt<M extends URIS3, E>(
  M: Monad3C<M, E>
): <R, A>(second: LazyArg<Kind3<M, R, E, Option<A>>>) => (first: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, Option<A>>
export declare function alt<M extends URIS2>(
  M: Monad2<M>
): <E, A>(second: LazyArg<Kind2<M, E, Option<A>>>) => (first: Kind2<M, E, Option<A>>) => Kind2<M, E, Option<A>>
export declare function alt<M extends URIS2, E>(
  M: Monad2C<M, E>
): <A>(second: LazyArg<Kind2<M, E, Option<A>>>) => (first: Kind2<M, E, Option<A>>) => Kind2<M, E, Option<A>>
export declare function alt<M extends URIS>(
  M: Monad1<M>
): <A>(second: LazyArg<Kind<M, Option<A>>>) => (first: Kind<M, Option<A>>) => Kind<M, Option<A>>
export declare function alt<M>(
  M: Monad<M>
): <A>(second: LazyArg<HKT<M, Option<A>>>) => (first: HKT<M, Option<A>>) => HKT<M, Option<A>>

Added in v2.10.0 v2.10.0 中添加

ap   美联社

Signature 签名

export declare function ap<F extends URIS4>(
  F: Apply4<F>
): <S, R, E, A>(
  fa: Kind4<F, S, R, E, Option<A>>
) => <B>(fab: Kind4<F, S, R, E, Option<(a: A) => B>>) => Kind4<F, S, R, E, Option<B>>
export declare function ap<F extends URIS3>(
  F: Apply3<F>
): <R, E, A>(
  fa: Kind3<F, R, E, Option<A>>
) => <B>(fab: Kind3<F, R, E, Option<(a: A) => B>>) => Kind3<F, R, E, Option<B>>
export declare function ap<F extends URIS3, E>(
  F: Apply3C<F, E>
): <R, A>(fa: Kind3<F, R, E, Option<A>>) => <B>(fab: Kind3<F, R, E, Option<(a: A) => B>>) => Kind3<F, R, E, Option<B>>
export declare function ap<F extends URIS2>(
  F: Apply2<F>
): <E, A>(fa: Kind2<F, E, Option<A>>) => <B>(fab: Kind2<F, E, Option<(a: A) => B>>) => Kind2<F, E, Option<B>>
export declare function ap<F extends URIS2, E>(
  F: Apply2C<F, E>
): <A>(fa: Kind2<F, E, Option<A>>) => <B>(fab: Kind2<F, E, Option<(a: A) => B>>) => Kind2<F, E, Option<B>>
export declare function ap<F extends URIS>(
  F: Apply1<F>
): <A>(fa: Kind<F, Option<A>>) => <B>(fab: Kind<F, Option<(a: A) => B>>) => Kind<F, Option<B>>
export declare function ap<F>(
  F: Apply<F>
): <A>(fa: HKT<F, Option<A>>) => <B>(fab: HKT<F, Option<(a: A) => B>>) => HKT<F, Option<B>>

Added in v2.10.0 v2.10.0 中添加

chain  

Signature 签名

export declare function chain<M extends URIS4>(
  M: Monad4<M>
): <A, S, R, E, B>(
  f: (a: A) => Kind4<M, S, R, E, Option<B>>
) => (ma: Kind4<M, S, R, E, Option<A>>) => Kind4<M, S, R, E, Option<B>>
export declare function chain<M extends URIS3>(
  M: Monad3<M>
): <A, R, E, B>(f: (a: A) => Kind3<M, R, E, Option<B>>) => (ma: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, Option<B>>
export declare function chain<M extends URIS3, E>(
  M: Monad3C<M, E>
): <A, R, B>(f: (a: A) => Kind3<M, R, E, Option<B>>) => (ma: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, Option<B>>
export declare function chain<M extends URIS2>(
  M: Monad2<M>
): <A, E, B>(f: (a: A) => Kind2<M, E, Option<B>>) => (ma: Kind2<M, E, Option<A>>) => Kind2<M, E, Option<B>>
export declare function chain<M extends URIS2, E>(
  M: Monad2C<M, E>
): <A, B>(f: (a: A) => Kind2<M, E, Option<B>>) => (ma: Kind2<M, E, Option<A>>) => Kind2<M, E, Option<B>>
export declare function chain<M extends URIS>(
  M: Monad1<M>
): <A, B>(f: (a: A) => Kind<M, Option<B>>) => (ma: Kind<M, Option<A>>) => Kind<M, Option<B>>
export declare function chain<M>(
  M: Monad<M>
): <A, B>(f: (a: A) => HKT<M, Option<B>>) => (ma: HKT<M, Option<A>>) => HKT<M, Option<B>>

Added in v2.10.0 v2.10.0 中添加

chainNullableK   链可空K

Signature 签名

export declare function chainNullableK<M extends URIS4>(
  M: Monad4<M>
): <A, B>(
  f: (a: A) => B | null | undefined
) => <S, R, E>(ma: Kind4<M, S, R, E, Option<A>>) => Kind4<M, S, R, E, Option<NonNullable<B>>>
export declare function chainNullableK<M extends URIS3>(
  M: Monad3<M>
): <A, B>(
  f: (a: A) => B | null | undefined
) => <R, E>(ma: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, Option<NonNullable<B>>>
export declare function chainNullableK<M extends URIS3, E>(
  M: Monad3C<M, E>
): <A, B>(
  f: (a: A) => B | null | undefined
) => <R>(ma: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, Option<NonNullable<B>>>
export declare function chainNullableK<M extends URIS2>(
  M: Monad2<M>
): <A, B>(f: (a: A) => B | null | undefined) => <E>(ma: Kind2<M, E, Option<A>>) => Kind2<M, E, Option<NonNullable<B>>>
export declare function chainNullableK<M extends URIS2, E>(
  M: Monad2C<M, E>
): <A, B>(f: (a: A) => B | null | undefined) => (ma: Kind2<M, E, Option<A>>) => Kind2<M, E, Option<NonNullable<B>>>
export declare function chainNullableK<M extends URIS>(
  M: Monad1<M>
): <A, B>(f: (a: A) => B | null | undefined) => (ma: Kind<M, Option<A>>) => Kind<M, Option<NonNullable<B>>>
export declare function chainNullableK<M>(
  M: Monad<M>
): <A, B>(f: (a: A) => B | null | undefined) => (ma: HKT<M, Option<A>>) => HKT<M, Option<NonNullable<B>>>

Added in v2.10.0 v2.10.0 中添加

chainOptionK   链选项K

Signature 签名

export declare function chainOptionK<M extends URIS4>(
  M: Monad4<M>
): <A, B>(f: (a: A) => Option<B>) => <S, R, E>(ma: Kind4<M, S, R, E, Option<A>>) => Kind4<M, S, R, E, Option<B>>
export declare function chainOptionK<M extends URIS3>(
  M: Monad3<M>
): <A, B>(f: (a: A) => Option<B>) => <R, E>(ma: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, Option<B>>
export declare function chainOptionK<M extends URIS3, E>(
  M: Monad3C<M, E>
): <A, B>(f: (a: A) => Option<B>) => <R>(ma: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, Option<B>>
export declare function chainOptionK<M extends URIS2>(
  M: Monad2<M>
): <A, B>(f: (a: A) => Option<B>) => <E>(ma: Kind2<M, E, Option<A>>) => Kind2<M, E, Option<B>>
export declare function chainOptionK<M extends URIS2, E>(
  M: Monad2C<M, E>
): <A, B>(f: (a: A) => Option<B>) => (ma: Kind2<M, E, Option<A>>) => Kind2<M, E, Option<B>>
export declare function chainOptionK<M extends URIS>(
  M: Monad1<M>
): <A, B>(f: (a: A) => Option<B>) => (ma: Kind<M, Option<A>>) => Kind<M, Option<B>>
export declare function chainOptionK<M>(
  M: Monad<M>
): <A, B>(f: (a: A) => Option<B>) => (ma: HKT<M, Option<A>>) => HKT<M, Option<B>>

Added in v2.10.0 v2.10.0 中添加

fromEither   来自任一

Signature 签名

export declare function fromEither<F extends URIS4>(
  F: Pointed4<F>
): <A, S, R, E>(e: Either<unknown, A>) => Kind4<F, S, R, E, Option<A>>
export declare function fromEither<F extends URIS3>(
  F: Pointed3<F>
): <A, R, E>(e: Either<unknown, A>) => Kind3<F, R, E, Option<A>>
export declare function fromEither<F extends URIS3, E>(
  F: Pointed3C<F, E>
): <A, R>(e: Either<unknown, A>) => Kind3<F, R, E, Option<A>>
export declare function fromEither<F extends URIS2>(
  F: Pointed2<F>
): <A, E>(e: Either<unknown, A>) => Kind2<F, E, Option<A>>
export declare function fromEither<F extends URIS2, E>(
  F: Pointed2C<F, E>
): <A>(e: Either<unknown, A>) => Kind2<F, E, Option<A>>
export declare function fromEither<F extends URIS2, E>(
  F: Pointed2C<F, E>
): <A>(e: Either<unknown, A>) => Kind2<F, E, Option<A>>
export declare function fromEither<F extends URIS>(F: Pointed1<F>): <A>(e: Either<unknown, A>) => Kind<F, Option<A>>
export declare function fromEither<F>(F: Pointed<F>): <A>(e: Either<unknown, A>) => HKT<F, Option<A>>

Added in v2.10.0 v2.10.0 中添加

fromF   来自F

Signature 签名

export declare function fromF<F extends URIS4>(
  F: Functor4<F>
): <S, R, E, A>(ma: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, Option<A>>
export declare function fromF<F extends URIS3>(
  F: Functor3<F>
): <R, E, A>(ma: Kind3<F, R, E, A>) => Kind3<F, R, E, Option<A>>
export declare function fromF<F extends URIS3, E>(
  F: Functor3C<F, E>
): <R, A>(ma: Kind3<F, R, E, A>) => Kind3<F, R, E, Option<A>>
export declare function fromF<F extends URIS2>(F: Functor2<F>): <E, A>(ma: Kind2<F, E, A>) => Kind2<F, E, Option<A>>
export declare function fromF<F extends URIS2, E>(F: Functor2C<F, E>): <A>(ma: Kind2<F, E, A>) => Kind2<F, E, Option<A>>
export declare function fromF<F extends URIS>(F: Functor1<F>): <A>(ma: Kind<F, A>) => Kind<F, Option<A>>
export declare function fromF<F>(F: Functor<F>): <A>(ma: HKT<F, A>) => HKT<F, Option<A>>

Added in v2.10.0 v2.10.0 中添加

fromNullable   来自可为空的

Signature 签名

export declare function fromNullable<F extends URIS4>(
  F: Pointed4<F>
): <A, S, R, E>(a: A) => Kind4<F, S, R, E, Option<NonNullable<A>>>
export declare function fromNullable<F extends URIS3>(
  F: Pointed3<F>
): <A, R, E>(a: A) => Kind3<F, R, E, Option<NonNullable<A>>>
export declare function fromNullable<F extends URIS3, E>(
  F: Pointed3C<F, E>
): <A, R>(a: A) => Kind3<F, R, E, Option<NonNullable<A>>>
export declare function fromNullable<F extends URIS2>(
  F: Pointed2<F>
): <A, E>(a: A) => Kind2<F, E, Option<NonNullable<A>>>
export declare function fromNullable<F extends URIS2, E>(
  F: Pointed2C<F, E>
): <A>(a: A) => Kind2<F, E, Option<NonNullable<A>>>
export declare function fromNullable<F extends URIS>(F: Pointed1<F>): <A>(a: A) => Kind<F, Option<NonNullable<A>>>
export declare function fromNullable<F>(F: Pointed<F>): <A>(a: A) => HKT<F, Option<NonNullable<A>>>

Added in v2.10.0 v2.10.0 中添加

fromNullableK  来自可空K

Signature 签名

export declare function fromNullableK<F extends URIS4>(
  F: Pointed4<F>
): <A extends ReadonlyArray<unknown>, B>(
  f: (...a: A) => B | null | undefined
) => <S, R, E>(...a: A) => Kind4<F, S, R, E, Option<NonNullable<B>>>
export declare function fromNullableK<F extends URIS3>(
  F: Pointed3<F>
): <A extends ReadonlyArray<unknown>, B>(
  f: (...a: A) => B | null | undefined
) => <R, E>(...a: A) => Kind3<F, R, E, Option<NonNullable<B>>>
export declare function fromNullableK<F extends URIS3, E>(
  F: Pointed3C<F, E>
): <A extends ReadonlyArray<unknown>, B>(
  f: (...a: A) => B | null | undefined
) => <R>(...a: A) => Kind3<F, R, E, Option<NonNullable<B>>>
export declare function fromNullableK<F extends URIS2>(
  F: Pointed2<F>
): <A extends ReadonlyArray<unknown>, B>(
  f: (...a: A) => B | null | undefined
) => <E>(...a: A) => Kind2<F, E, Option<NonNullable<B>>>
export declare function fromNullableK<F extends URIS2, E>(
  F: Pointed2C<F, E>
): <A extends ReadonlyArray<unknown>, B>(
  f: (...a: A) => B | null | undefined
) => (...a: A) => Kind2<F, E, Option<NonNullable<B>>>
export declare function fromNullableK<F extends URIS>(
  F: Pointed1<F>
): <A extends ReadonlyArray<unknown>, B>(
  f: (...a: A) => B | null | undefined
) => (...a: A) => Kind<F, Option<NonNullable<B>>>
export declare function fromNullableK<F>(
  F: Pointed<F>
): <A extends ReadonlyArray<unknown>, B>(
  f: (...a: A) => B | null | undefined
) => (...a: A) => HKT<F, Option<NonNullable<B>>>

Added in v2.10.0 v2.10.0 中添加

fromOptionK   来自选项K

Signature 签名

export declare function fromOptionK<F extends URIS4>(
  F: Pointed4<F>
): <A extends ReadonlyArray<unknown>, B>(
  f: (...a: A) => Option<B>
) => <S, R, E>(...a: A) => Kind4<F, S, R, E, Option<B>>
export declare function fromOptionK<F extends URIS3>(
  F: Pointed3<F>
): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => <R, E>(...a: A) => Kind3<F, R, E, Option<B>>
export declare function fromOptionK<F extends URIS3, E>(
  F: Pointed3C<F, E>
): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => <R>(...a: A) => Kind3<F, R, E, Option<B>>
export declare function fromOptionK<F extends URIS2>(
  F: Pointed2<F>
): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => <E>(...a: A) => Kind2<F, E, Option<B>>
export declare function fromOptionK<F extends URIS2, E>(
  F: Pointed2C<F, E>
): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => Kind2<F, E, Option<B>>
export declare function fromOptionK<F extends URIS>(
  F: Pointed1<F>
): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => Kind<F, Option<B>>
export declare function fromOptionK<F>(
  F: Pointed<F>
): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => HKT<F, Option<B>>

Added in v2.10.0 v2.10.0 中添加

getOrElse  获取或否则

Signature 签名

export declare function getOrElse<M extends URIS4>(
  M: Monad4<M>
): <S, R, E, A>(onNone: LazyArg<Kind4<M, S, R, E, A>>) => (fa: Kind4<M, S, R, E, Option<A>>) => Kind4<M, S, R, E, A>
export declare function getOrElse<M extends URIS3>(
  M: Monad3<M>
): <R, E, A>(onNone: LazyArg<Kind3<M, R, E, A>>) => (fa: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, A>
export declare function getOrElse<M extends URIS3, E>(
  M: Monad3C<M, E>
): <R, A>(onNone: LazyArg<Kind3<M, R, E, A>>) => (fa: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, A>
export declare function getOrElse<M extends URIS2>(
  M: Monad2<M>
): <E, A>(onNone: LazyArg<Kind2<M, E, A>>) => (fa: Kind2<M, E, Option<A>>) => Kind2<M, E, A>
export declare function getOrElse<M extends URIS2, E>(
  M: Monad2C<M, E>
): <A>(onNone: LazyArg<Kind2<M, E, A>>) => (fa: Kind2<M, E, Option<A>>) => Kind2<M, E, A>
export declare function getOrElse<M extends URIS>(
  M: Monad1<M>
): <A>(onNone: LazyArg<Kind<M, A>>) => (fa: Kind<M, Option<A>>) => Kind<M, A>
export declare function getOrElse<M>(
  M: Monad<M>
): <A>(onNone: LazyArg<HKT<M, A>>) => (fa: HKT<M, Option<A>>) => HKT<M, A>

Added in v2.10.0 v2.10.0 中添加

map   地图

Signature 签名

export declare function map<F extends URIS4>(
  F: Functor4<F>
): <A, B>(f: (a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, Option<A>>) => Kind4<F, S, R, E, Option<B>>
export declare function map<F extends URIS3>(
  F: Functor3<F>
): <A, B>(f: (a: A) => B) => <R, E>(fa: Kind3<F, R, E, Option<A>>) => Kind3<F, R, E, Option<B>>
export declare function map<F extends URIS3, E>(
  F: Functor3C<F, E>
): <A, B>(f: (a: A) => B) => <R>(fa: Kind3<F, R, E, Option<A>>) => Kind3<F, R, E, Option<B>>
export declare function map<F extends URIS2>(
  F: Functor2<F>
): <A, B>(f: (a: A) => B) => <E>(fa: Kind2<F, E, Option<A>>) => Kind2<F, E, Option<B>>
export declare function map<F extends URIS2, E>(
  F: Functor2C<F, E>
): <A, B>(f: (a: A) => B) => (fa: Kind2<F, E, Option<A>>) => Kind2<F, E, Option<B>>
export declare function map<F extends URIS>(
  F: Functor1<F>
): <A, B>(f: (a: A) => B) => (fa: Kind<F, Option<A>>) => Kind<F, Option<B>>
export declare function map<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => (fa: HKT<F, Option<A>>) => HKT<F, Option<B>>

Added in v2.10.0 v2.10.0 中添加

matchE   匹配E

Signature 签名

export declare function matchE<M extends URIS4>(
  M: Chain4<M>
): <S, R, E, B, A>(
  onNone: () => Kind4<M, S, R, E, B>,
  onSome: (a: A) => Kind4<M, S, R, E, B>
) => (ma: Kind4<M, S, R, E, Option<A>>) => Kind4<M, S, R, E, B>
export declare function matchE<M extends URIS3>(
  M: Chain3<M>
): <R, E, B, A>(
  onNone: () => Kind3<M, R, E, B>,
  onSome: (a: A) => Kind3<M, R, E, B>
) => (ma: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, B>
export declare function matchE<M extends URIS3, E>(
  M: Chain3C<M, E>
): <R, B, A>(
  onNone: () => Kind3<M, R, E, B>,
  onSome: (a: A) => Kind3<M, R, E, B>
) => (ma: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, B>
export declare function matchE<M extends URIS2>(
  M: Chain2<M>
): <E, B, A>(
  onNone: () => Kind2<M, E, B>,
  onSome: (a: A) => Kind2<M, E, B>
) => (ma: Kind2<M, E, Option<A>>) => Kind2<M, E, B>
export declare function matchE<M extends URIS2, E>(
  M: Chain2C<M, E>
): <B, A>(
  onNone: () => Kind2<M, E, B>,
  onSome: (a: A) => Kind2<M, E, B>
) => (ma: Kind2<M, E, Option<A>>) => Kind2<M, E, B>
export declare function matchE<M extends URIS>(
  M: Chain1<M>
): <B, A>(onNone: () => Kind<M, B>, onSome: (a: A) => Kind<M, B>) => (ma: Kind<M, Option<A>>) => Kind<M, B>
export declare function matchE<M>(
  M: Chain<M>
): <B, A>(onNone: () => HKT<M, B>, onSome: (a: A) => HKT<M, B>) => (ma: HKT<M, Option<A>>) => HKT<M, B>

Added in v2.10.0 v2.10.0 中添加

some   一些

Signature 签名

export declare function some<F extends URIS4>(F: Pointed4<F>): <A, S, R, E>(a: A) => Kind4<F, S, R, E, Option<A>>
export declare function some<F extends URIS3>(F: Pointed3<F>): <A, R, E>(a: A) => Kind3<F, R, E, Option<A>>
export declare function some<F extends URIS3, E>(F: Pointed3C<F, E>): <A, R>(a: A) => Kind3<F, R, E, Option<A>>
export declare function some<F extends URIS2>(F: Pointed2<F>): <A, E>(a: A) => Kind2<F, E, Option<A>>
export declare function some<F extends URIS2, E>(F: Pointed2C<F, E>): <A>(a: A) => Kind2<F, E, Option<A>>
export declare function some<F extends URIS>(F: Pointed1<F>): <A>(a: A) => Kind<F, Option<A>>
export declare function some<F>(F: Pointed<F>): <A>(a: A) => HKT<F, Option<A>>

Added in v2.10.0 v2.10.0 中添加

zero  

Signature 签名

export declare function zero<F extends URIS4>(F: Pointed4<F>): <S, R, E, A>() => Kind4<F, S, R, E, Option<A>>
export declare function zero<F extends URIS3>(F: Pointed3<F>): <R, E, A>() => Kind3<F, R, E, Option<A>>
export declare function zero<F extends URIS3, E>(F: Pointed3C<F, E>): <R, A>() => Kind3<F, R, E, Option<A>>
export declare function zero<F extends URIS2>(F: Pointed2<F>): <E, A>() => Kind2<F, E, Option<A>>
export declare function zero<F extends URIS2, E>(F: Pointed2C<F, E>): <A>() => Kind2<F, E, Option<A>>
export declare function zero<F extends URIS>(F: Pointed1<F>): <A>() => Kind<F, Option<A>>
export declare function zero<F>(F: Pointed<F>): <A>() => HKT<F, Option<A>>

Added in v2.10.0 v2.10.0 中添加

zone of death
死亡地带

OptionM1 选项M1 (interface)   (界面)

Signature 签名

export interface OptionM1<M extends URIS> extends ApplicativeComposition11<M, O.URI> {
  readonly chain: <A, B>(ma: OptionT1<M, A>, f: (a: A) => OptionT1<M, B>) => OptionT1<M, B>
  readonly alt: <A>(fa: OptionT1<M, A>, that: LazyArg<OptionT1<M, A>>) => OptionT1<M, A>
  readonly fold: <A, R>(ma: OptionT1<M, A>, onNone: LazyArg<Kind<M, R>>, onSome: (a: A) => Kind<M, R>) => Kind<M, R>
  readonly getOrElse: <A>(ma: OptionT1<M, A>, onNone: LazyArg<Kind<M, A>>) => Kind<M, A>
  readonly fromM: <A>(ma: Kind<M, A>) => OptionT1<M, A>
  readonly none: <A = never>() => OptionT1<M, A>
}

Added in v2.0.0 v2.0.0 中添加

OptionM2C 选项M2C (interface)   (界面)

Signature 签名

export interface OptionM2C<M extends URIS2, E> extends ApplicativeComposition2C1<M, O.URI, E> {
  readonly chain: <A, B>(ma: OptionT2<M, E, A>, f: (a: A) => OptionT2<M, E, B>) => OptionT2<M, E, B>
  readonly alt: <A>(fa: OptionT2<M, E, A>, that: LazyArg<OptionT2<M, E, A>>) => OptionT2<M, E, A>
  readonly fold: <A, R>(
    ma: OptionT2<M, E, A>,
    onNone: LazyArg<Kind2<M, E, R>>,
    onSome: (a: A) => Kind2<M, E, R>
  ) => Kind2<M, E, R>
  readonly getOrElse: <A>(ma: OptionT2<M, E, A>, onNone: LazyArg<Kind2<M, E, A>>) => Kind2<M, E, A>
  readonly fromM: <A>(ma: Kind2<M, E, A>) => OptionT2<M, E, A>
  readonly none: <A = never>() => OptionT2<M, E, A>
}

Added in v2.2.0 v2.2.0中添加

OptionM2 选项M2 (interface)   (界面)

Signature 签名

export interface OptionM2<M extends URIS2> extends ApplicativeComposition21<M, O.URI> {
  readonly chain: <E, A, B>(ma: OptionT2<M, E, A>, f: (a: A) => OptionT2<M, E, B>) => OptionT2<M, E, B>
  readonly alt: <E, A>(fa: OptionT2<M, E, A>, that: LazyArg<OptionT2<M, E, A>>) => OptionT2<M, E, A>
  readonly fold: <E, A, R>(
    ma: OptionT2<M, E, A>,
    onNone: LazyArg<Kind2<M, E, R>>,
    onSome: (a: A) => Kind2<M, E, R>
  ) => Kind2<M, E, R>
  readonly getOrElse: <E, A>(ma: OptionT2<M, E, A>, onNone: LazyArg<Kind2<M, E, A>>) => Kind2<M, E, A>
  readonly fromM: <E, A>(ma: Kind2<M, E, A>) => OptionT2<M, E, A>
  readonly none: <E = never, A = never>() => OptionT2<M, E, A>
}

Added in v2.0.0 v2.0.0 中添加

OptionM 选项M (interface)   (界面)

Signature 签名

export interface OptionM<M> extends ApplicativeCompositionHKT1<M, O.URI> {
  readonly chain: <A, B>(ma: OptionT<M, A>, f: (a: A) => OptionT<M, B>) => OptionT<M, B>
  readonly alt: <A>(fa: OptionT<M, A>, that: LazyArg<OptionT<M, A>>) => OptionT<M, A>
  readonly fold: <A, R>(ma: OptionT<M, A>, onNone: LazyArg<HKT<M, R>>, onSome: (a: A) => HKT<M, R>) => HKT<M, R>
  readonly getOrElse: <A>(ma: OptionT<M, A>, onNone: LazyArg<HKT<M, A>>) => HKT<M, A>
  readonly fromM: <A>(ma: HKT<M, A>) => OptionT<M, A>
  readonly none: <A = never>() => OptionT<M, A>
}

Added in v2.0.0 v2.0.0 中添加

OptionT1 选项T1 (type alias)   (类型别名)

Signature 签名

export type OptionT1<M extends URIS, A> = Kind<M, Option<A>>

Added in v2.0.0 v2.0.0 中添加

OptionT2 选项T2 (type alias)   (类型别名)

Signature 签名

export type OptionT2<M extends URIS2, E, A> = Kind2<M, E, Option<A>>

Added in v2.0.0 v2.0.0 中添加

OptionT 选项T (interface)   (界面)

Signature 签名

export interface OptionT<M, A> extends HKT<M, Option<A>> {}

Added in v2.0.0 v2.0.0 中添加

getOptionM 获取选项M

Signature 签名

export declare function getOptionM<M extends URIS2>(M: Monad2<M>): OptionM2<M>
export declare function getOptionM<M extends URIS2, E>(M: Monad2C<M, E>): OptionM2C<M, E>
export declare function getOptionM<M extends URIS>(M: Monad1<M>): OptionM1<M>
export declare function getOptionM<M>(M: Monad<M>): OptionM<M>

Added in v2.0.0 v2.0.0 中添加

Ord overview  订单概览

The Ord type class represents types which support comparisons with a total order.
Ord 类型类表示支持与全序比较的类型。

Instances should satisfy the laws of total orderings:
实例应满足全序法则:

  1. Reflexivity: S.compare(a, a) <= 0 自反性: S.compare(a, a) <= 0
  2. Antisymmetry: if S.compare(a, b) <= 0 and S.compare(b, a) <= 0 then a <-> b
    反对称:如果 S.compare(a, b) <= 0S.compare(b, a) <= 0a <-> b
  3. Transitivity: if S.compare(a, b) <= 0 and S.compare(b, c) <= 0 then S.compare(a, c) <= 0
    传递性:如果 S.compare(a, b) <= 0S.compare(b, c) <= 0S.compare(a, c) <= 0

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


constructors  构造函数

fromCompare   来自比较

Signature 签名

export declare const fromCompare: <A>(compare: (first: A, second: A) => Ordering) => Ord<A>

Added in v2.0.0 v2.0.0 中添加

defaults   默认值

equalsDefault   等于默认值

Signature 签名

export declare const equalsDefault: <A>(compare: (first: A, second: A) => Ordering) => (x: A, y: A) => boolean

Added in v2.10.0 v2.10.0 中添加

instances   实例

Contravariant  逆变

Signature 签名

export declare const Contravariant: Contravariant1<'Ord'>

Added in v2.7.0 v2.7.0 中添加

getMonoid   获取Monoid

Returns a Monoid such that:
返回一个 Monoid ,这样:

  • its concat(ord1, ord2) operation will order first by ord1, and then by ord2
    它的 concat(ord1, ord2) 操作将首先按 ord1 排序,然后按 ord2 排序
  • its empty value is an Ord that always considers compared elements equal
    它的 empty 值是 Ord ,总是认为比较的元素相等

Signature 签名

export declare const getMonoid: <A = never>() => Monoid<Ord<A>>

Example 例子

import { sort } from 'fp-ts/Array'
import { contramap, reverse, getMonoid } from 'fp-ts/Ord'
import * as S from 'fp-ts/string'
import * as B from 'fp-ts/boolean'
import { pipe } from 'fp-ts/function'
import { concatAll } from 'fp-ts/Monoid'
import * as N from 'fp-ts/number'

interface User {
  readonly id: number
  readonly name: string
  readonly age: number
  readonly rememberMe: boolean
}

const byName = pipe(
  S.Ord,
  contramap((p: User) => p.name)
)

const byAge = pipe(
  N.Ord,
  contramap((p: User) => p.age)
)

const byRememberMe = pipe(
  B.Ord,
  contramap((p: User) => p.rememberMe)
)

const M = getMonoid<User>()

const users: Array<User> = [
  { id: 1, name: 'Guido', age: 47, rememberMe: false },
  { id: 2, name: 'Guido', age: 46, rememberMe: true },
  { id: 3, name: 'Giulio', age: 44, rememberMe: false },
  { id: 4, name: 'Giulio', age: 44, rememberMe: true },
]

// sort by name, then by age, then by `rememberMe`
const O1 = concatAll(M)([byName, byAge, byRememberMe])
assert.deepStrictEqual(sort(O1)(users), [
  { id: 3, name: 'Giulio', age: 44, rememberMe: false },
  { id: 4, name: 'Giulio', age: 44, rememberMe: true },
  { id: 2, name: 'Guido', age: 46, rememberMe: true },
  { id: 1, name: 'Guido', age: 47, rememberMe: false },
])

// now `rememberMe = true` first, then by name, then by age
const O2 = concatAll(M)([reverse(byRememberMe), byName, byAge])
assert.deepStrictEqual(sort(O2)(users), [
  { id: 4, name: 'Giulio', age: 44, rememberMe: true },
  { id: 2, name: 'Guido', age: 46, rememberMe: true },
  { id: 3, name: 'Giulio', age: 44, rememberMe: false },
  { id: 1, name: 'Guido', age: 47, rememberMe: false },
])

Added in v2.4.0 v2.4.0中添加

getSemigroup   获取半群

A typical use case for the Semigroup instance of Ord is merging two or more orderings.
OrdSemigroup 实例的典型用例是合并两个或多个排序。

For example the following snippet builds an Ord for a type User which sorts by created date descending, and then lastName
例如,以下代码片段为类型 User 构建一个 Ord ,该类型按 created 日期降序排序,然后按 lastName 排序

Signature 签名

export declare const getSemigroup: <A = never>() => Semigroup<Ord<A>>

Example 例子

import * as D from 'fp-ts/Date'
import { pipe } from 'fp-ts/function'
import { contramap, getSemigroup, Ord, reverse } from 'fp-ts/Ord'
import * as RA from 'fp-ts/ReadonlyArray'
import * as S from 'fp-ts/string'

interface User {
  readonly id: string
  readonly lastName: string
  readonly created: Date
}

const ordByLastName: Ord<User> = pipe(
  S.Ord,
  contramap((user) => user.lastName)
)

const ordByCreated: Ord<User> = pipe(
  D.Ord,
  contramap((user) => user.created)
)

const ordUserByCreatedDescThenLastName = getSemigroup<User>().concat(reverse(ordByCreated), ordByLastName)

assert.deepStrictEqual(
  RA.sort(ordUserByCreatedDescThenLastName)([
    { id: 'c', lastName: 'd', created: new Date(1973, 10, 30) },
    { id: 'a', lastName: 'b', created: new Date(1973, 10, 30) },
    { id: 'e', lastName: 'f', created: new Date(1980, 10, 30) },
  ]),
  [
    { id: 'e', lastName: 'f', created: new Date(1980, 10, 30) },
    { id: 'a', lastName: 'b', created: new Date(1973, 10, 30) },
    { id: 'c', lastName: 'd', created: new Date(1973, 10, 30) },
  ]
)

Added in v2.0.0 v2.0.0 中添加

model   模型

Ord (interface)  订单(接口)

Signature 签名

export interface Ord<A> extends Eq<A> {
  readonly compare: (first: A, second: A) => Ordering
}

Added in v2.0.0 v2.0.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'Ord'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

between  之间

Test whether a value is between a minimum and a maximum (inclusive)
测试一个值是否在最小值和最大值之间(含)

Signature 签名

export declare const between: <A>(O: Ord<A>) => (low: A, hi: A) => (a: A) => boolean

Added in v2.0.0 v2.0.0 中添加

clamp   夹钳

Clamp a value between a minimum and a maximum
将值限制在最小值和最大值之间

Signature 签名

export declare const clamp: <A>(O: Ord<A>) => (low: A, hi: A) => (a: A) => A

Added in v2.0.0 v2.0.0 中添加

contramap   对比图

A typical use case for contramap would be like, given some User type, to construct an Ord<User>.
contramap 的典型用例类似于,给定一些 User 类型,构造一个 Ord<User>

We can do so with a function from User -> X where X is some value that we know how to compare for ordering (meaning we have an Ord<X>)
我们可以使用 User -> X 中的函数来做到这一点,其中 X 是我们知道如何比较排序的某个值(意味着我们有一个 Ord<X>

For example, given the following User type, there are lots of possible choices for X, but let’s say we want to sort a list of users by lastName.
例如,给定以下 User 类型, X 有很多可能的选择,但假设我们想按 lastName 对用户列表进行排序。

If we have a way of comparing lastNames for ordering (ordLastName: Ord<string>) and we know how to go from User -> string, using contramap we can do this
如果我们有一种方法比较 lastName s 的排序 ( ordLastName: Ord<string> ) 并且我们知道如何从 User -> string 开始,使用 contramap 我们可以做到这一点

Signature 签名

export declare const contramap: <A, B>(f: (b: B) => A) => (fa: Ord<A>) => Ord<B>

Example 例子

import { pipe } from 'fp-ts/function'
import { contramap, Ord } from 'fp-ts/Ord'
import * as RA from 'fp-ts/ReadonlyArray'
import * as S from 'fp-ts/string'

interface User {
  readonly firstName: string
  readonly lastName: string
}

const ordLastName: Ord<string> = S.Ord

const ordByLastName: Ord<User> = pipe(
  ordLastName,
  contramap((user) => user.lastName)
)

assert.deepStrictEqual(
  RA.sort(ordByLastName)([
    { firstName: 'a', lastName: 'd' },
    { firstName: 'c', lastName: 'b' },
  ]),
  [
    { firstName: 'c', lastName: 'b' },
    { firstName: 'a', lastName: 'd' },
  ]
)

Added in v2.0.0 v2.0.0 中添加

equals   等于

Signature 签名

export declare const equals: <A>(O: Ord<A>) => (second: A) => (first: A) => boolean

Added in v2.11.0 v2.11.0 中添加

geq   盖克

Test whether one value is non-strictly greater than another
测试一个值是否非严格大于另一个值

Signature 签名

export declare const geq: <A>(O: Ord<A>) => (first: A, second: A) => boolean

Added in v2.0.0 v2.0.0 中添加

gt   GT

Test whether one value is strictly greater than another
测试一个值是否严格大于另一个值

Signature 签名

export declare const gt: <A>(O: Ord<A>) => (first: A, second: A) => boolean

Added in v2.0.0 v2.0.0 中添加

leq   勒克

Test whether one value is non-strictly less than another
测试一个值是否非严格小于另一个值

Signature 签名

export declare const leq: <A>(O: Ord<A>) => (first: A, second: A) => boolean

Added in v2.0.0 v2.0.0 中添加

lt  

Test whether one value is strictly less than another
测试一个值是否严格小于另一个值

Signature 签名

export declare const lt: <A>(O: Ord<A>) => (first: A, second: A) => boolean

Added in v2.0.0 v2.0.0 中添加

max   最大限度

Take the maximum of two values. If they are considered equal, the first argument is chosen
取两个值中的最大值。如果它们被认为相等,则选择第一个参数

Signature 签名

export declare const max: <A>(O: Ord<A>) => (first: A, second: A) => A

Added in v2.0.0 v2.0.0 中添加

min   分钟

Take the minimum of two values. If they are considered equal, the first argument is chosen
取两个值中的最小值。如果它们被认为相等,则选择第一个参数

Signature 签名

export declare const min: <A>(O: Ord<A>) => (first: A, second: A) => A

Added in v2.0.0 v2.0.0 中添加

reverse   撤销

Signature 签名

export declare const reverse: <A>(O: Ord<A>) => Ord<A>

Added in v2.10.0 v2.10.0 中添加

trivial   琐碎的

Signature 签名

export declare const trivial: Ord<unknown>

Added in v2.11.0 v2.11.0 中添加

tuple   元组

Given a tuple of Ords returns an Ord for the tuple.
给定一个 Ord s 的元组,返回该元组的 Ord

Signature 签名

export declare const tuple: <A extends readonly unknown[]>(...ords: { [K in keyof A]: Ord<A[K]> }) => Ord<Readonly<A>>

Example 例子

import { tuple } from 'fp-ts/Ord'
import * as B from 'fp-ts/boolean'
import * as S from 'fp-ts/string'
import * as N from 'fp-ts/number'

const O = tuple(S.Ord, N.Ord, B.Ord)
assert.strictEqual(O.compare(['a', 1, true], ['b', 2, true]), -1)
assert.strictEqual(O.compare(['a', 1, true], ['a', 2, true]), -1)
assert.strictEqual(O.compare(['a', 1, true], ['a', 1, false]), 1)

Added in v2.10.0 v2.10.0 中添加

zone of death
死亡地带

getDualOrd 获得双阶

Use reverse instead. 请改用 reverse

Signature 签名

export declare const getDualOrd: <A>(O: Ord<A>) => Ord<A>

Added in v2.0.0 v2.0.0 中添加

getTupleOrd 获取元组顺序

Use tuple instead. 请改用 tuple

Signature 签名

export declare const getTupleOrd: <T extends readonly Ord<any>[]>(
  ...ords: T
) => Ord<{ [K in keyof T]: T[K] extends Ord<infer A> ? A : never }>

Added in v2.0.0 v2.0.0 中添加

ordBoolean 订单布尔值

Use Ord instead. 请改用 Ord

Signature 签名

export declare const ordBoolean: Ord<boolean>

Added in v2.0.0 v2.0.0 中添加

ordDate 订单日期

Use Ord instead. 请改用 Ord

Signature 签名

export declare const ordDate: Ord<Date>

Added in v2.0.0 v2.0.0 中添加

ordNumber 订单号

Use Ord instead. 请改用 Ord

Signature 签名

export declare const ordNumber: Ord<number>

Added in v2.0.0 v2.0.0 中添加

ordString 排序字符串

Use Ord instead. 请改用 Ord

Signature 签名

export declare const ordString: Ord<string>

Added in v2.0.0 v2.0.0 中添加

ord 秩序

Use Contravariant instead. 请改用 Contravariant

Signature 签名

export declare const ord: Contravariant1<'Ord'>

Added in v2.0.0 v2.0.0 中添加

Ordering overview  订购概览

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


instances   实例

Eq   方程

Signature 签名

export declare const Eq: E.Eq<Ordering>

Added in v2.10.0 v2.10.0 中添加

Monoid   幺半群

Signature 签名

export declare const Monoid: M.Monoid<Ordering>

Added in v2.10.0 v2.10.0 中添加

Semigroup   半群

Signature 签名

export declare const Semigroup: S.Semigroup<Ordering>

Added in v2.10.0 v2.10.0 中添加

model   模型

Ordering (type alias)
排序(类型别名)

Signature 签名

export type Ordering = -1 | 0 | 1

Added in v2.0.0 v2.0.0 中添加

pattern matching   模式匹配

match   匹配

Signature 签名

export declare const match: <A>(onLessThan: () => A, onEqual: () => A, onGreaterThan: () => A) => (o: Ordering) => A

Added in v2.10.0 v2.10.0 中添加

matchW   匹配W

Less strict version of match.
match 的不太严格版本。

The W suffix (short for Widening) means that the handler return types will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const matchW: <A, B, C>(
  onLessThan: () => A,
  onEqual: () => B,
  onGreaterThan: () => C
) => (o: Ordering) => A | B | C

Added in v2.12.0 v2.12.0 中添加

utils   实用程序

reverse   撤销

Signature 签名

export declare const reverse: (o: Ordering) => Ordering

Added in v2.10.0 v2.10.0 中添加

sign   符号

Signature 签名

export declare const sign: (n: number) => Ordering

Added in v2.0.0 v2.0.0 中添加

zone of death
死亡地带

eqOrdering EQ排序

Use Eq instead 使用 Eq 代替

Signature 签名

export declare const eqOrdering: E.Eq<Ordering>

Added in v2.0.0 v2.0.0 中添加

invert 倒置

Use reverse instead. 请改用 reverse

Signature 签名

export declare const invert: (o: Ordering) => Ordering

Added in v2.0.0 v2.0.0 中添加

monoidOrdering 幺半群排序

Use Monoid instead 使用 Monoid 代替

Signature 签名

export declare const monoidOrdering: M.Monoid<Ordering>

Added in v2.4.0 v2.4.0中添加

semigroupOrdering 半群排序

Use Semigroup instead 使用 Semigroup 代替

Signature 签名

export declare const semigroupOrdering: S.Semigroup<Ordering>

Added in v2.0.0 v2.0.0 中添加

pipeable overview  可管道概述

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


pipeable helper   可管道助手

alt   替代

Returns a pipeable alt 返回一个可管道化的 alt

Signature 签名

export declare function alt<F extends URIS4>(
  F: Alt4<F>
): <S, R, E, A>(that: LazyArg<Kind4<F, S, R, E, A>>) => (fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>
export declare function alt<F extends URIS3>(
  F: Alt3<F>
): <R, E, A>(that: LazyArg<Kind3<F, R, E, A>>) => (fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>
export declare function alt<F extends URIS3, E>(
  F: Alt3C<F, E>
): <R, A>(that: LazyArg<Kind3<F, R, E, A>>) => (fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>
export declare function alt<F extends URIS2>(
  F: Alt2<F>
): <E, A>(that: LazyArg<Kind2<F, E, A>>) => (fa: Kind2<F, E, A>) => Kind2<F, E, A>
export declare function alt<F extends URIS2, E>(
  F: Alt2C<F, E>
): <A>(that: LazyArg<Kind2<F, E, A>>) => (fa: Kind2<F, E, A>) => Kind2<F, E, A>
export declare function alt<F extends URIS>(
  F: Alt1<F>
): <A>(that: LazyArg<Kind<F, A>>) => (fa: Kind<F, A>) => Kind<F, A>
export declare function alt<F>(F: Alt<F>): <A>(that: LazyArg<HKT<F, A>>) => (fa: HKT<F, A>) => HKT<F, A>

Added in v2.13.0 v2.13.0 中添加

ap   美联社

Returns a pipeable ap 返回一个可管道化的 ap

Signature 签名

export declare function ap<F extends URIS4>(
  F: Apply4<F>
): <S, R, E, A>(fa: Kind4<F, S, R, E, A>) => <B>(fab: Kind4<F, S, R, E, (a: A) => B>) => Kind4<F, S, R, E, B>
export declare function ap<F extends URIS3>(
  F: Apply3<F>
): <R, E, A>(fa: Kind3<F, R, E, A>) => <B>(fab: Kind3<F, R, E, (a: A) => B>) => Kind3<F, R, E, B>
export declare function ap<F extends URIS3, E>(
  F: Apply3C<F, E>
): <R, A>(fa: Kind3<F, R, E, A>) => <B>(fab: Kind3<F, R, E, (a: A) => B>) => Kind3<F, R, E, B>
export declare function ap<F extends URIS2>(
  F: Apply2<F>
): <E, A>(fa: Kind2<F, E, A>) => <B>(fab: Kind2<F, E, (a: A) => B>) => Kind2<F, E, B>
export declare function ap<F extends URIS2, E>(
  F: Apply2C<F, E>
): <A>(fa: Kind2<F, E, A>) => <B>(fab: Kind2<F, E, (a: A) => B>) => Kind2<F, E, B>
export declare function ap<F extends URIS>(
  F: Apply1<F>
): <A>(fa: Kind<F, A>) => <B>(fab: Kind<F, (a: A) => B>) => Kind<F, B>
export declare function ap<F>(F: Apply<F>): <A>(fa: HKT<F, A>) => <B>(fab: HKT<F, (a: A) => B>) => HKT<F, B>

Added in v2.13.0 v2.13.0 中添加

bimap   双图

Returns a pipeable bimap 返回一个可管道化的 bimap

Signature 签名

export declare function bimap<F extends URIS4>(
  F: Bifunctor4<F>
): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => <S, R>(fea: Kind4<F, S, R, E, A>) => Kind4<F, S, R, G, B>
export declare function bimap<F extends URIS3>(
  F: Bifunctor3<F>
): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => <R>(fea: Kind3<F, R, E, A>) => Kind3<F, R, G, B>
export declare function bimap<F extends URIS3, E>(
  F: Bifunctor3C<F, E>
): <G, A, B>(f: (e: E) => G, g: (a: A) => B) => <R>(fea: Kind3<F, R, E, A>) => Kind3<F, R, G, B>
export declare function bimap<F extends URIS2>(
  F: Bifunctor2<F>
): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fea: Kind2<F, E, A>) => Kind2<F, G, B>
export declare function bimap<F extends URIS2, E>(
  F: Bifunctor2C<F, E>
): <G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fea: Kind2<F, E, A>) => Kind2<F, G, B>
export declare function bimap<F>(
  F: Bifunctor<F>
): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fea: HKT2<F, E, A>) => HKT2<F, G, B>

Added in v2.13.0 v2.13.0 中添加

chain  

Returns a pipeable chain 返回一个可管道化的 chain

Signature 签名

export declare function chain<F extends URIS4>(
  F: Chain4<F>
): <A, S, R, E, B>(f: (a: A) => Kind4<F, S, R, E, B>) => (fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>
export declare function chain<F extends URIS3>(
  F: Chain3<F>
): <A, R, E, B>(f: (a: A) => Kind3<F, R, E, B>) => (fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
export declare function chain<F extends URIS3, E>(
  F: Chain3C<F, E>
): <A, R, B>(f: (a: A) => Kind3<F, R, E, B>) => (fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
export declare function chain<F extends URIS2>(
  F: Chain2<F>
): <A, E, B>(f: (a: A) => Kind2<F, E, B>) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>
export declare function chain<F extends URIS2, E>(
  F: Chain2C<F, E>
): <A, B>(f: (a: A) => Kind2<F, E, B>) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>
export declare function chain<F extends URIS>(
  F: Chain1<F>
): <A, B>(f: (a: A) => Kind<F, B>) => (fa: Kind<F, A>) => Kind<F, B>
export declare function chain<F>(F: Chain<F>): <A, B>(f: (a: A) => HKT<F, B>) => (fa: HKT<F, A>) => HKT<F, B>

Added in v2.13.0 v2.13.0 中添加

compose   撰写

Returns a pipeable compose 返回一个可管道化的 compose

Signature 签名

export declare function compose<F extends URIS4>(
  F: Semigroupoid4<F>
): <S, R, E, A>(ea: Kind4<F, S, R, E, A>) => <B>(ab: Kind4<F, S, R, A, B>) => Kind4<F, S, R, E, B>
export declare function compose<F extends URIS3>(
  F: Semigroupoid3<F>
): <R, E, A>(ea: Kind3<F, R, E, A>) => <B>(ab: Kind3<F, R, A, B>) => Kind3<F, R, E, B>
export declare function compose<F extends URIS3, E>(
  F: Semigroupoid3C<F, E>
): <R, A>(ea: Kind3<F, R, E, A>) => <B>(ab: Kind3<F, R, A, B>) => Kind3<F, R, E, B>
export declare function compose<F extends URIS2>(
  F: Semigroupoid2<F>
): <E, A>(ea: Kind2<F, E, A>) => <B>(ab: Kind2<F, A, B>) => Kind2<F, E, B>
export declare function compose<F extends URIS2, E>(
  F: Semigroupoid2C<F, E>
): <A>(ea: Kind2<F, E, A>) => <B>(ab: Kind2<F, A, B>) => Kind2<F, E, B>
export declare function compose<F>(
  F: Semigroupoid<F>
): <E, A>(ea: HKT2<F, E, A>) => <B>(ab: HKT2<F, A, B>) => HKT2<F, E, B>

Added in v2.13.0 v2.13.0 中添加

contramap   对比图

Returns a pipeable contramap 返回一个可管道化的 contramap

Signature 签名

export declare function contramap<F extends URIS4>(
  F: Contravariant4<F>
): <A, B>(f: (b: B) => A) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>
export declare function contramap<F extends URIS3>(
  F: Contravariant3<F>
): <A, B>(f: (b: B) => A) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
export declare function contramap<F extends URIS3, E>(
  F: Contravariant3C<F, E>
): <A, B>(f: (b: B) => A) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
export declare function contramap<F extends URIS2>(
  F: Contravariant2<F>
): <A, B>(f: (b: B) => A) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>
export declare function contramap<F extends URIS2, E>(
  F: Contravariant2C<F, E>
): <A, B>(f: (b: B) => A) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>
export declare function contramap<F extends URIS>(
  F: Contravariant1<F>
): <A, B>(f: (b: B) => A) => (fa: Kind<F, A>) => Kind<F, B>
export declare function contramap<F>(F: Contravariant<F>): <A, B>(f: (b: B) => A) => (fa: HKT<F, A>) => HKT<F, B>

Added in v2.13.0 v2.13.0 中添加

extend   延长

Returns a pipeable extend 返回一个可管道化的 extend

Signature 签名

export declare function extend<F extends URIS4>(
  F: Extend4<F>
): <S, R, E, A, B>(f: (wa: Kind4<F, S, R, E, A>) => B) => (wa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>
export declare function extend<F extends URIS3>(
  F: Extend3<F>
): <R, E, A, B>(f: (wa: Kind3<F, R, E, A>) => B) => (wa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
export declare function extend<F extends URIS3, E>(
  F: Extend3C<F, E>
): <R, A, B>(f: (wa: Kind3<F, R, E, A>) => B) => (wa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
export declare function extend<F extends URIS2>(
  F: Extend2<F>
): <E, A, B>(f: (wa: Kind2<F, E, A>) => B) => (wa: Kind2<F, E, A>) => Kind2<F, E, B>
export declare function extend<F extends URIS2, E>(
  F: Extend2C<F, E>
): <A, B>(f: (wa: Kind2<F, E, A>) => B) => (wa: Kind2<F, E, A>) => Kind2<F, E, B>
export declare function extend<F extends URIS>(
  F: Extend1<F>
): <A, B>(f: (wa: Kind<F, A>) => B) => (wa: Kind<F, A>) => Kind<F, B>
export declare function extend<F>(F: Extend<F>): <A, B>(f: (wa: HKT<F, A>) => B) => (wa: HKT<F, A>) => HKT<F, B>

Added in v2.13.0 v2.13.0 中添加

filter   筛选

Returns a pipeable filter 返回一个可管道化的 filter

Signature 签名

export declare function filter<F extends URIS4>(
  F: Filterable4<F>
): {
  <A, B extends A>(refinement: Refinement<A, B>): <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>
  <A>(predicate: Predicate<A>): <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>
}
export declare function filter<F extends URIS3>(
  F: Filterable3<F>
): {
  <A, B extends A>(refinement: Refinement<A, B>): <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
  <A>(predicate: Predicate<A>): <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>
}
export declare function filter<F extends URIS3, E>(
  F: Filterable3C<F, E>
): {
  <A, B extends A>(refinement: Refinement<A, B>): <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
  <A>(predicate: Predicate<A>): <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>
}
export declare function filter<F extends URIS2>(
  F: Filterable2<F>
): {
  <A, B extends A>(refinement: Refinement<A, B>): <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>
  <A>(predicate: Predicate<A>): <E>(fa: Kind2<F, E, A>) => Kind2<F, E, A>
}
export declare function filter<F extends URIS2, E>(
  F: Filterable2C<F, E>
): {
  <A, B extends A>(refinement: Refinement<A, B>): (fa: Kind2<F, E, A>) => Kind2<F, E, B>
  <A>(predicate: Predicate<A>): (fa: Kind2<F, E, A>) => Kind2<F, E, A>
}
export declare function filter<F extends URIS>(
  F: Filterable1<F>
): {
  <A, B extends A>(refinement: Refinement<A, B>): (fa: Kind<F, A>) => Kind<F, B>
  <A>(predicate: Predicate<A>): (fa: Kind<F, A>) => Kind<F, A>
}
export declare function filter<F>(F: Filterable<F>): {
  <A, B extends A>(refinement: Refinement<A, B>): (fa: HKT<F, A>) => HKT<F, B>
  <A>(predicate: Predicate<A>): (fa: HKT<F, A>) => HKT<F, A>
}

Added in v2.13.0 v2.13.0 中添加

filterMap   过滤映射

Returns a pipeable filterMap 返回一个可管道化的 filterMap

Signature 签名

export declare function filterMap<F extends URIS4>(
  F: Filterable4<F>
): <A, B>(f: (a: A) => Option<B>) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>
export declare function filterMap<F extends URIS3>(
  F: Filterable3<F>
): <A, B>(f: (a: A) => Option<B>) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
export declare function filterMap<F extends URIS3, E>(
  F: Filterable3C<F, E>
): <A, B>(f: (a: A) => Option<B>) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
export declare function filterMap<F extends URIS2>(
  F: Filterable2<F>
): <A, B>(f: (a: A) => Option<B>) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>
export declare function filterMap<F extends URIS2, E>(
  F: Filterable2C<F, E>
): <A, B>(f: (a: A) => Option<B>) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>
export declare function filterMap<F extends URIS>(
  F: Filterable1<F>
): <A, B>(f: (a: A) => Option<B>) => (fa: Kind<F, A>) => Kind<F, B>
export declare function filterMap<F>(F: Filterable<F>): <A, B>(f: (a: A) => Option<B>) => (fa: HKT<F, A>) => HKT<F, B>

Added in v2.13.0 v2.13.0 中添加

filterMapWithIndex   带索引的过滤映射

Returns a pipeable filterMapWithIndex 返回一个可管道化的 filterMapWithIndex

Signature 签名

export declare function filterMapWithIndex<F extends URIS4, I>(
  F: FilterableWithIndex4<F, I>
): <A, B>(f: (i: I, a: A) => Option<B>) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>
export declare function filterMapWithIndex<F extends URIS3, I>(
  F: FilterableWithIndex3<F, I>
): <A, B>(f: (i: I, a: A) => Option<B>) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
export declare function filterMapWithIndex<F extends URIS3, I, E>(
  F: FilterableWithIndex3C<F, I, E>
): <A, B>(f: (i: I, a: A) => Option<B>) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
export declare function filterMapWithIndex<F extends URIS2, I>(
  F: FilterableWithIndex2<F, I>
): <A, B>(f: (i: I, a: A) => Option<B>) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>
export declare function filterMapWithIndex<F extends URIS2, I, E>(
  F: FilterableWithIndex2C<F, I, E>
): <A, B>(f: (i: I, a: A) => Option<B>) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>
export declare function filterMapWithIndex<F extends URIS, I>(
  F: FilterableWithIndex1<F, I>
): <A, B>(f: (i: I, a: A) => Option<B>) => (fa: Kind<F, A>) => Kind<F, B>
export declare function filterMapWithIndex<F, I>(
  F: FilterableWithIndex<F, I>
): <A, B>(f: (i: I, a: A) => Option<B>) => (fa: HKT<F, A>) => HKT<F, B>

Added in v2.13.0 v2.13.0 中添加

filterWithIndex   带索引的过滤器

Returns a pipeable filterWithIndex 返回一个可管道化的 filterWithIndex

Signature 签名

export declare function filterWithIndex<F extends URIS4, I>(
  F: FilterableWithIndex4<F, I>
): {
  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): <S, R, E>(
    fa: Kind4<F, S, R, E, A>
  ) => Kind4<F, S, R, E, B>
  <A>(predicate: PredicateWithIndex<I, A>): <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>
}
export declare function filterWithIndex<F extends URIS3, I>(
  F: FilterableWithIndex3<F, I>
): {
  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
  <A>(predicate: PredicateWithIndex<I, A>): <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>
}
export declare function filterWithIndex<F extends URIS3, I, E>(
  F: FilterableWithIndex3C<F, I, E>
): {
  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
  <A>(predicate: PredicateWithIndex<I, A>): <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>
}
export declare function filterWithIndex<F extends URIS2, I>(
  F: FilterableWithIndex2<F, I>
): {
  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>
  <A>(predicate: PredicateWithIndex<I, A>): <E>(fa: Kind2<F, E, A>) => Kind2<F, E, A>
}
export declare function filterWithIndex<F extends URIS2, E, I>(
  F: FilterableWithIndex2C<F, I, E>
): {
  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): (fa: Kind2<F, E, A>) => Kind2<F, E, B>
  <A>(predicate: PredicateWithIndex<I, A>): (fa: Kind2<F, E, A>) => Kind2<F, E, A>
}
export declare function filterWithIndex<F extends URIS, I>(
  F: FilterableWithIndex1<F, I>
): {
  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): (fa: Kind<F, A>) => Kind<F, B>
  <A>(predicate: PredicateWithIndex<I, A>): (fa: Kind<F, A>) => Kind<F, A>
}
export declare function filterWithIndex<F, I>(
  F: FilterableWithIndex<F, I>
): {
  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): (fa: HKT<F, A>) => HKT<F, B>
  <A>(predicate: PredicateWithIndex<I, A>): (fa: HKT<F, A>) => HKT<F, A>
}

Added in v2.13.0 v2.13.0 中添加

foldMap   折叠图

Returns a pipeable foldMap 返回一个可管道化的 foldMap

Signature 签名

export declare function foldMap<F extends URIS4>(
  F: Foldable4<F>
): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => M
export declare function foldMap<F extends URIS3>(
  F: Foldable3<F>
): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <R, E>(fa: Kind3<F, R, E, A>) => M
export declare function foldMap<F extends URIS3, E>(
  F: Foldable3C<F, E>
): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <R>(fa: Kind3<F, R, E, A>) => M
export declare function foldMap<F extends URIS2>(
  F: Foldable2<F>
): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <E>(fa: Kind2<F, E, A>) => M
export declare function foldMap<F extends URIS2, E>(
  F: Foldable2C<F, E>
): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: Kind2<F, E, A>) => M
export declare function foldMap<F extends URIS>(
  F: Foldable1<F>
): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: Kind<F, A>) => M
export declare function foldMap<F>(F: Foldable<F>): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: HKT<F, A>) => M

Added in v2.13.0 v2.13.0 中添加

foldMapWithIndex   带索引的折叠地图

Returns a pipeable foldMapWithIndex 返回一个可管道化的 foldMapWithIndex

Signature 签名

export declare function foldMapWithIndex<F extends URIS4, I>(
  F: FoldableWithIndex4<F, I>
): <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => M
export declare function foldMapWithIndex<F extends URIS3, I>(
  F: FoldableWithIndex3<F, I>
): <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => <R, E>(fa: Kind3<F, R, E, A>) => M
export declare function foldMapWithIndex<F extends URIS3, I, E>(
  F: FoldableWithIndex3C<F, I, E>
): <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => <R>(fa: Kind3<F, R, E, A>) => M
export declare function foldMapWithIndex<F extends URIS2, I>(
  F: FoldableWithIndex2<F, I>
): <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => <E>(fa: Kind2<F, E, A>) => M
export declare function foldMapWithIndex<F extends URIS2, I, E>(
  F: FoldableWithIndex2C<F, I, E>
): <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => (fa: Kind2<F, E, A>) => M
export declare function foldMapWithIndex<F extends URIS, I>(
  F: FoldableWithIndex1<F, I>
): <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => (fa: Kind<F, A>) => M
export declare function foldMapWithIndex<F, I>(
  F: FoldableWithIndex<F, I>
): <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => (fa: HKT<F, A>) => M

Added in v2.13.0 v2.13.0 中添加

map   地图

Returns a pipeable map 返回一个可管道化的 map

Signature 签名

export declare function map<F extends URIS4>(
  F: Functor4<F>
): <A, B>(f: (a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>
export declare function map<F extends URIS3>(
  F: Functor3<F>
): <A, B>(f: (a: A) => B) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
export declare function map<F extends URIS3, E>(
  F: Functor3C<F, E>
): <A, B>(f: (a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
export declare function map<F extends URIS2>(
  F: Functor2<F>
): <A, B>(f: (a: A) => B) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>
export declare function map<F extends URIS2, E>(
  F: Functor2C<F, E>
): <A, B>(f: (a: A) => B) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>
export declare function map<F extends URIS>(F: Functor1<F>): <A, B>(f: (a: A) => B) => (fa: Kind<F, A>) => Kind<F, B>
export declare function map<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => (fa: HKT<F, A>) => HKT<F, B>

Added in v2.13.0 v2.13.0 中添加

mapLeft   地图左

Returns a pipeable mapLeft 返回一个可管道化的 mapLeft

Signature 签名

export declare function mapLeft<F extends URIS4>(
  F: Bifunctor4<F>
): <E, G>(f: (e: E) => G) => <S, R, A>(fea: Kind4<F, S, R, E, A>) => Kind4<F, S, R, G, A>
export declare function mapLeft<F extends URIS3>(
  F: Bifunctor3<F>
): <E, G>(f: (e: E) => G) => <R, A>(fea: Kind3<F, R, E, A>) => Kind3<F, R, G, A>
export declare function mapLeft<F extends URIS3, E>(
  F: Bifunctor3C<F, E>
): <E, G>(f: (e: E) => G) => <R, A>(fea: Kind3<F, R, E, A>) => Kind3<F, R, G, A>
export declare function mapLeft<F extends URIS2>(
  F: Bifunctor2<F>
): <E, G>(f: (e: E) => G) => <A>(fea: Kind2<F, E, A>) => Kind2<F, G, A>
export declare function mapLeft<F extends URIS2, E>(
  F: Bifunctor2C<F, E>
): <E, G>(f: (e: E) => G) => <A>(fea: Kind2<F, E, A>) => Kind2<F, G, A>
export declare function mapLeft<F>(F: Bifunctor<F>): <E, G>(f: (e: E) => G) => <A>(fea: HKT2<F, E, A>) => HKT2<F, G, A>

Added in v2.13.0 v2.13.0 中添加

mapWithIndex   带索引的映射

Returns a pipeable mapWithIndex 返回一个可管道化的 mapWithIndex

Signature 签名

export declare function mapWithIndex<F extends URIS4, I>(
  F: FunctorWithIndex4<F, I>
): <A, B>(f: (i: I, a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>
export declare function mapWithIndex<F extends URIS3, I>(
  F: FunctorWithIndex3<F, I>
): <A, B>(f: (i: I, a: A) => B) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
export declare function mapWithIndex<F extends URIS3, I, E>(
  F: FunctorWithIndex3C<F, I, E>
): <A, B>(f: (i: I, a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
export declare function mapWithIndex<F extends URIS2, I>(
  F: FunctorWithIndex2<F, I>
): <A, B>(f: (i: I, a: A) => B) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>
export declare function mapWithIndex<F extends URIS2, I, E>(
  F: FunctorWithIndex2C<F, I, E>
): <A, B>(f: (i: I, a: A) => B) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>
export declare function mapWithIndex<F extends URIS, I>(
  F: FunctorWithIndex1<F, I>
): <A, B>(f: (i: I, a: A) => B) => (fa: Kind<F, A>) => Kind<F, B>
export declare function mapWithIndex<F, I>(
  F: FunctorWithIndex<F, I>
): <A, B>(f: (i: I, a: A) => B) => (fa: HKT<F, A>) => HKT<F, B>

Added in v2.13.0 v2.13.0 中添加

partition   分割

Returns a pipeable partition 返回一个可管道化的 partition

Signature 签名

export declare function partition<F extends URIS4>(
  F: Filterable4<F>
): {
  <A, B extends A>(refinement: Refinement<A, B>): <S, R, E>(
    fa: Kind4<F, S, R, E, A>
  ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, B>>
  <A>(predicate: Predicate<A>): <S, R, E>(
    fa: Kind4<F, S, R, E, A>
  ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, A>>
}
export declare function partition<F extends URIS3>(
  F: Filterable3<F>
): {
  <A, B extends A>(refinement: Refinement<A, B>): <R, E>(
    fa: Kind3<F, R, E, A>
  ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>
  <A>(predicate: Predicate<A>): <R, E>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>
}
export declare function partition<F extends URIS3, E>(
  F: Filterable3C<F, E>
): {
  <A, B extends A>(refinement: Refinement<A, B>): <R>(
    fa: Kind3<F, R, E, A>
  ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>
  <A>(predicate: Predicate<A>): <R>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>
}
export declare function partition<F extends URIS2>(
  F: Filterable2<F>
): {
  <A, B extends A>(refinement: Refinement<A, B>): <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>
  <A>(predicate: Predicate<A>): <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, A>>
}
export declare function partition<F extends URIS2, E>(
  F: Filterable2C<F, E>
): {
  <A, B extends A>(refinement: Refinement<A, B>): (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>
  <A>(predicate: Predicate<A>): (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, A>>
}
export declare function partition<F extends URIS>(
  F: Filterable1<F>
): {
  <A, B extends A>(refinement: Refinement<A, B>): (fa: Kind<F, A>) => Separated<Kind<F, A>, Kind<F, B>>
  <A>(predicate: Predicate<A>): (fa: Kind<F, A>) => Separated<Kind<F, A>, Kind<F, A>>
}
export declare function partition<F>(F: Filterable<F>): {
  <A, B extends A>(refinement: Refinement<A, B>): (fa: HKT<F, A>) => Separated<HKT<F, A>, HKT<F, B>>
  <A>(predicate: Predicate<A>): (fa: HKT<F, A>) => Separated<HKT<F, A>, HKT<F, A>>
}

Added in v2.13.0 v2.13.0 中添加

partitionMap   分区图

Returns a pipeable partitionMap 返回一个可管道化的 partitionMap

Signature 签名

export declare function partitionMap<F extends URIS4>(
  F: Filterable4<F>
): <A, B, C>(
  f: (a: A) => Either<B, C>
) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Separated<Kind4<F, S, R, E, B>, Kind4<F, S, R, E, C>>
export declare function partitionMap<F extends URIS3>(
  F: Filterable3<F>
): <A, B, C>(
  f: (a: A) => Either<B, C>
) => <R, E>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>
export declare function partitionMap<F extends URIS3, E>(
  F: Filterable3C<F, E>
): <A, B, C>(f: (a: A) => Either<B, C>) => <R>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>
export declare function partitionMap<F extends URIS2>(
  F: Filterable2<F>
): <A, B, C>(f: (a: A) => Either<B, C>) => <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>
export declare function partitionMap<F extends URIS2, E>(
  F: Filterable2C<F, E>
): <A, B, C>(f: (a: A) => Either<B, C>) => (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>
export declare function partitionMap<F extends URIS>(
  F: Filterable1<F>
): <A, B, C>(f: (a: A) => Either<B, C>) => (fa: Kind<F, A>) => Separated<Kind<F, B>, Kind<F, C>>
export declare function partitionMap<F>(
  F: Filterable<F>
): <A, B, C>(f: (a: A) => Either<B, C>) => (fa: HKT<F, A>) => Separated<HKT<F, B>, HKT<F, C>>

Added in v2.13.0 v2.13.0 中添加

partitionMapWithIndex   带索引的分区映射

Returns a pipeable partitionMapWithIndex 返回一个可管道化的 partitionMapWithIndex

Signature 签名

export declare function partitionMapWithIndex<F extends URIS4, I>(
  F: FilterableWithIndex4<F, I>
): <A, B, C>(
  f: (i: I, a: A) => Either<B, C>
) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Separated<Kind4<F, S, R, E, B>, Kind4<F, S, R, E, C>>
export declare function partitionMapWithIndex<F extends URIS3, I>(
  F: FilterableWithIndex3<F, I>
): <A, B, C>(
  f: (i: I, a: A) => Either<B, C>
) => <R, E>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>
export declare function partitionMapWithIndex<F extends URIS3, I, E>(
  F: FilterableWithIndex3C<F, I, E>
): <A, B, C>(
  f: (i: I, a: A) => Either<B, C>
) => <R>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>
export declare function partitionMapWithIndex<F extends URIS2, I>(
  F: FilterableWithIndex2<F, I>
): <A, B, C>(f: (i: I, a: A) => Either<B, C>) => <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>
export declare function partitionMapWithIndex<F extends URIS2, I, E>(
  F: FilterableWithIndex2C<F, I, E>
): <A, B, C>(f: (i: I, a: A) => Either<B, C>) => (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>
export declare function partitionMapWithIndex<F extends URIS, I>(
  F: FilterableWithIndex1<F, I>
): <A, B, C>(f: (i: I, a: A) => Either<B, C>) => (fa: Kind<F, A>) => Separated<Kind<F, B>, Kind<F, C>>
export declare function partitionMapWithIndex<F, I>(
  F: FilterableWithIndex<F, I>
): <A, B, C>(f: (i: I, a: A) => Either<B, C>) => (fa: HKT<F, A>) => Separated<HKT<F, B>, HKT<F, C>>

Added in v2.13.0 v2.13.0 中添加

partitionWithIndex   带索引分区

Returns a pipeable partitionWithIndex 返回一个可管道化的 partitionWithIndex

Signature 签名

export declare function partitionWithIndex<F extends URIS4, I>(
  F: FilterableWithIndex4<F, I>
): {
  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): <S, R, E>(
    fa: Kind4<F, S, R, E, A>
  ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, B>>
  <A>(predicate: PredicateWithIndex<I, A>): <S, R, E>(
    fa: Kind4<F, S, R, E, A>
  ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, A>>
}
export declare function partitionWithIndex<F extends URIS3, I>(
  F: FilterableWithIndex3<F, I>
): {
  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): <R, E>(
    fa: Kind3<F, R, E, A>
  ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>
  <A>(predicate: PredicateWithIndex<I, A>): <R, E>(
    fa: Kind3<F, R, E, A>
  ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>
}
export declare function partitionWithIndex<F extends URIS3, I, E>(
  F: FilterableWithIndex3C<F, I, E>
): {
  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): <R>(
    fa: Kind3<F, R, E, A>
  ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>
  <A>(predicate: PredicateWithIndex<I, A>): <R>(
    fa: Kind3<F, R, E, A>
  ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>
}
export declare function partitionWithIndex<F extends URIS2, I>(
  F: FilterableWithIndex2<F, I>
): {
  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): <E>(
    fa: Kind2<F, E, A>
  ) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>
  <A>(predicate: PredicateWithIndex<I, A>): <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, A>>
}
export declare function partitionWithIndex<F extends URIS2, I, E>(
  F: FilterableWithIndex2C<F, I, E>
): {
  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): (
    fa: Kind2<F, E, A>
  ) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>
  <A>(predicate: PredicateWithIndex<I, A>): (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, A>>
}
export declare function partitionWithIndex<F extends URIS, I>(
  F: FilterableWithIndex1<F, I>
): {
  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): (fa: Kind<F, A>) => Separated<Kind<F, A>, Kind<F, B>>
  <A>(predicate: PredicateWithIndex<I, A>): (fa: Kind<F, A>) => Separated<Kind<F, A>, Kind<F, A>>
}
export declare function partitionWithIndex<F, I>(
  F: FilterableWithIndex<F, I>
): {
  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): (fa: HKT<F, A>) => Separated<HKT<F, A>, HKT<F, B>>
  <A>(predicate: PredicateWithIndex<I, A>): (fa: HKT<F, A>) => Separated<HKT<F, A>, HKT<F, A>>
}

Added in v2.13.0 v2.13.0 中添加

promap   普罗普

Returns a pipeable promap 返回一个可管道化的 promap

Signature 签名

export declare function promap<F extends URIS4>(
  F: Profunctor4<F>
): <E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => <S, R>(fbc: Kind4<F, S, R, E, A>) => Kind4<F, S, R, D, B>
export declare function promap<F extends URIS3>(
  F: Profunctor3<F>
): <E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => <R>(fbc: Kind3<F, R, E, A>) => Kind3<F, R, D, B>
export declare function promap<F extends URIS3, E>(
  F: Profunctor3C<F, E>
): <A, D, B>(f: (d: D) => E, g: (a: A) => B) => <R>(fbc: Kind3<F, R, E, A>) => Kind3<F, R, D, B>
export declare function promap<F extends URIS2>(
  F: Profunctor2<F>
): <E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: Kind2<F, E, A>) => Kind2<F, D, B>
export declare function promap<F extends URIS2, E>(
  F: Profunctor2C<F, E>
): <A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: Kind2<F, E, A>) => Kind2<F, D, B>
export declare function promap<F>(
  F: Profunctor<F>
): <E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: HKT2<F, E, A>) => HKT2<F, D, B>

Added in v2.13.0 v2.13.0 中添加

reduce   减少

Returns a pipeable reduce 返回一个可管道化的 reduce

Signature 签名

export declare function reduce<F extends URIS4>(
  F: Foldable4<F>
): <A, B>(b: B, f: (b: B, a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => B
export declare function reduce<F extends URIS3>(
  F: Foldable3<F>
): <A, B>(b: B, f: (b: B, a: A) => B) => <R, E>(fa: Kind3<F, R, E, A>) => B
export declare function reduce<F extends URIS3, E>(
  F: Foldable3C<F, E>
): <A, B>(b: B, f: (b: B, a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => B
export declare function reduce<F extends URIS2>(
  F: Foldable2<F>
): <A, B>(b: B, f: (b: B, a: A) => B) => <E>(fa: Kind2<F, E, A>) => B
export declare function reduce<F extends URIS2, E>(
  F: Foldable2C<F, E>
): <A, B>(b: B, f: (b: B, a: A) => B) => (fa: Kind2<F, E, A>) => B
export declare function reduce<F extends URIS>(
  F: Foldable1<F>
): <A, B>(b: B, f: (b: B, a: A) => B) => (fa: Kind<F, A>) => B
export declare function reduce<F>(F: Foldable<F>): <A, B>(b: B, f: (b: B, a: A) => B) => (fa: HKT<F, A>) => B

Added in v2.13.0 v2.13.0 中添加

reduceRight   减少右

Returns a pipeable reduceRight 返回一个可管道化的 reduceRight

Signature 签名

export declare function reduceRight<F extends URIS4>(
  F: Foldable4<F>
): <A, B>(b: B, f: (a: A, b: B) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => B
export declare function reduceRight<F extends URIS3>(
  F: Foldable3<F>
): <A, B>(b: B, f: (a: A, b: B) => B) => <R, E>(fa: Kind3<F, R, E, A>) => B
export declare function reduceRight<F extends URIS3, E>(
  F: Foldable3C<F, E>
): <A, B>(b: B, f: (a: A, b: B) => B) => <R>(fa: Kind3<F, R, E, A>) => B
export declare function reduceRight<F extends URIS2>(
  F: Foldable2<F>
): <A, B>(b: B, f: (a: A, b: B) => B) => <E>(fa: Kind2<F, E, A>) => B
export declare function reduceRight<F extends URIS2, E>(
  F: Foldable2C<F, E>
): <A, B>(b: B, f: (a: A, b: B) => B) => (fa: Kind2<F, E, A>) => B
export declare function reduceRight<F extends URIS>(
  F: Foldable1<F>
): <A, B>(b: B, f: (a: A, b: B) => B) => (fa: Kind<F, A>) => B
export declare function reduceRight<F>(F: Foldable<F>): <A, B>(b: B, f: (a: A, b: B) => B) => (fa: HKT<F, A>) => B

Added in v2.13.0 v2.13.0 中添加

reduceRightWithIndex   减少右索引

Returns a pipeable reduceRightWithIndex 返回一个可管道化的 reduceRightWithIndex

Signature 签名

export declare function reduceRightWithIndex<F extends URIS4, I>(
  F: FoldableWithIndex4<F, I>
): <A, B>(b: B, f: (i: I, a: A, b: B) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => B
export declare function reduceRightWithIndex<F extends URIS3, I>(
  F: FoldableWithIndex3<F, I>
): <A, B>(b: B, f: (i: I, a: A, b: B) => B) => <R, E>(fa: Kind3<F, R, E, A>) => B
export declare function reduceRightWithIndex<F extends URIS3, I, E>(
  F: FoldableWithIndex3C<F, I, E>
): <A, B>(b: B, f: (i: I, a: A, b: B) => B) => <R>(fa: Kind3<F, R, E, A>) => B
export declare function reduceRightWithIndex<F extends URIS2, I>(
  F: FoldableWithIndex2<F, I>
): <A, B>(b: B, f: (i: I, a: A, b: B) => B) => <E>(fa: Kind2<F, E, A>) => B
export declare function reduceRightWithIndex<F extends URIS2, I, E>(
  F: FoldableWithIndex2C<F, I, E>
): <A, B>(b: B, f: (i: I, a: A, b: B) => B) => (fa: Kind2<F, E, A>) => B
export declare function reduceRightWithIndex<F extends URIS, I>(
  F: FoldableWithIndex1<F, I>
): <A, B>(b: B, f: (i: I, a: A, b: B) => B) => (fa: Kind<F, A>) => B
export declare function reduceRightWithIndex<F, I>(
  F: FoldableWithIndex<F, I>
): <A, B>(b: B, f: (i: I, a: A, b: B) => B) => (fa: HKT<F, A>) => B

Added in v2.13.0 v2.13.0 中添加

reduceWithIndex  减少索引

Returns a pipeable reduceWithIndex 返回一个可管道化的 reduceWithIndex

Signature 签名

export declare function reduceWithIndex<F extends URIS4, I>(
  F: FoldableWithIndex4<F, I>
): <A, B>(b: B, f: (i: I, b: B, a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => B
export declare function reduceWithIndex<F extends URIS3, I>(
  F: FoldableWithIndex3<F, I>
): <A, B>(b: B, f: (i: I, b: B, a: A) => B) => <R, E>(fa: Kind3<F, R, E, A>) => B
export declare function reduceWithIndex<F extends URIS3, I, E>(
  F: FoldableWithIndex3C<F, I, E>
): <A, B>(b: B, f: (i: I, b: B, a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => B
export declare function reduceWithIndex<F extends URIS2, I>(
  F: FoldableWithIndex2<F, I>
): <A, B>(b: B, f: (i: I, b: B, a: A) => B) => <E>(fa: Kind2<F, E, A>) => B
export declare function reduceWithIndex<F extends URIS2, I, E>(
  F: FoldableWithIndex2C<F, I, E>
): <A, B>(b: B, f: (i: I, b: B, a: A) => B) => (fa: Kind2<F, E, A>) => B
export declare function reduceWithIndex<F extends URIS, I>(
  F: FoldableWithIndex1<F, I>
): <A, B>(b: B, f: (i: I, b: B, a: A) => B) => (fa: Kind<F, A>) => B
export declare function reduceWithIndex<F, I>(
  F: FoldableWithIndex<F, I>
): <A, B>(b: B, f: (i: I, b: B, a: A) => B) => (fa: HKT<F, A>) => B

Added in v2.13.0 v2.13.0 中添加

utils   实用程序

PipeableAlt3C PipeableAlt3C (interface)   (界面)

Signature 签名

export interface PipeableAlt3C<F extends URIS3, E> {
  readonly alt: <R, A>(that: LazyArg<Kind3<F, R, E, A>>) => (fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>
}

Added in v2.2.0 v2.2.0中添加

PipeableApply3C PipeableApply3C (interface)   (界面)

Signature 签名

export interface PipeableApply3C<F extends URIS3, E> extends PipeableFunctor3C<F, E> {
  readonly ap: <R, A>(fa: Kind3<F, R, E, A>) => <B>(fab: Kind3<F, R, E, (a: A) => B>) => Kind3<F, R, E, B>
  readonly apFirst: <R, B>(fb: Kind3<F, R, E, B>) => <A>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>
  readonly apSecond: <R, B>(fb: Kind3<F, R, E, B>) => <A>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
}

Added in v2.2.0 v2.2.0中添加

PipeableBifunctor3C PipeableBifunctor3C (interface)   (界面)

Signature 签名

export interface PipeableBifunctor3C<F extends URIS3, E> {
  readonly bimap: <G, A, B>(f: (e: E) => G, g: (a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, G, B>
  readonly mapLeft: <G>(f: (e: E) => G) => <R, A>(fa: Kind3<F, R, E, A>) => Kind3<F, R, G, A>
}

Added in v2.2.0 v2.2.0中添加

PipeableChain3C PipeableChain3C (interface)   (界面)

Signature 签名

export interface PipeableChain3C<F extends URIS3, E> extends PipeableApply3C<F, E> {
  readonly chain: <R, A, B>(f: (a: A) => Kind3<F, R, E, B>) => (ma: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
  readonly chainFirst: <R, A, B>(f: (a: A) => Kind3<F, R, E, B>) => (ma: Kind3<F, R, E, A>) => Kind3<F, R, E, A>
  readonly flatten: <R, A>(mma: Kind3<F, R, E, Kind3<F, R, E, A>>) => Kind3<F, R, E, A>
}

Added in v2.2.0 v2.2.0中添加

PipeableCompactable3C 管道式紧凑式3C (interface)   (界面)

Signature 签名

export interface PipeableCompactable3C<F extends URIS3, E> {
  readonly compact: <R, A>(fa: Kind3<F, R, E, Option<A>>) => Kind3<F, R, E, A>
  readonly separate: <R, A, B>(fa: Kind3<F, R, E, Either<A, B>>) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>
}

Added in v2.2.0 v2.2.0中添加

PipeableContravariant3C Pipeable逆变3C (interface)   (界面)

Signature 签名

export interface PipeableContravariant3C<F extends URIS3, E> {
  readonly contramap: <A, B>(f: (b: B) => A) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
}

Added in v2.2.0 v2.2.0中添加

PipeableExtend3C PipeableExtend3C (interface)   (界面)

Signature 签名

export interface PipeableExtend3C<F extends URIS3, E> extends PipeableFunctor3C<F, E> {
  readonly extend: <R, A, B>(f: (wa: Kind3<F, R, E, A>) => B) => (wa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
  readonly duplicate: <R, A>(wa: Kind3<F, R, E, A>) => Kind3<F, R, E, Kind3<F, R, E, A>>
}

Added in v2.2.0 v2.2.0中添加

PipeableFilterable3C PipeableFilterable3C (interface)   (界面)

Signature 签名

export interface PipeableFilterable3C<F extends URIS3, E> extends PipeableCompactable3C<F, E> {
  readonly filter: {
    <A, B extends A>(refinement: Refinement<A, B>): <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
    <A>(predicate: Predicate<A>): <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>
  }
  readonly filterMap: <A, B>(f: (a: A) => Option<B>) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>
  readonly partition: {
    <A, B extends A>(refinement: Refinement<A, B>): <R>(
      fa: Kind3<F, R, E, A>
    ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>
    <A>(predicate: Predicate<A>): <R>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>
  }
  readonly partitionMap: <A, B, C>(
    f: (a: A) => Either<B, C>
  ) => <R>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>
}

Added in v2.2.0 v2.2.0中添加

PipeableFilterableWithIndex3C
PipeableFilterableWithIndex3C
(interface)   (界面)

Signature 签名

export interface PipeableFilterableWithIndex3C<F extends URIS3, I, E> extends PipeableFilterable3C<F, E> {
  readonly filterWithIndex: {
    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
    <A>(predicateWithIndex: PredicateWithIndex<I, A>): <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>
  }
  readonly filterMapWithIndex: <A, B>(f: (i: I, a: A) => Option<B>) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>
  readonly partitionWithIndex: {
    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): <R>(
      fa: Kind3<F, R, E, A>
    ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>
    <A>(predicateWithIndex: PredicateWithIndex<I, A>): <R>(
      fa: Kind3<F, R, E, A>
    ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>
  }
  readonly partitionMapWithIndex: <A, B, C>(
    f: (i: I, a: A) => Either<B, C>
  ) => <R>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>
}

Added in v2.2.0 v2.2.0中添加

PipeableFoldable3C 可管道可折叠3C (interface)   (界面)

Signature 签名

export interface PipeableFoldable3C<F extends URIS3, E> {
  readonly reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => B
  readonly foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <R>(fa: Kind3<F, R, E, A>) => M
  readonly reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <R>(fa: Kind3<F, R, E, A>) => B
}

Added in v2.2.0 v2.2.0中添加

PipeableFoldableWithIndex3C
PipeableFoldableWithIndex3C
(interface)   (界面)

Signature 签名

export interface PipeableFoldableWithIndex3C<F extends URIS3, I, E> extends PipeableFoldable3C<F, E> {
  readonly reduceWithIndex: <A, B>(b: B, f: (i: I, b: B, a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => B
  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => <R>(fa: Kind3<F, R, E, A>) => M
  readonly reduceRightWithIndex: <A, B>(b: B, f: (i: I, a: A, b: B) => B) => <R>(fa: Kind3<F, R, E, A>) => B
}

Added in v2.2.0 v2.2.0中添加

PipeableFunctor3C PipeableFunctor3C (interface)   (界面)

Signature 签名

export interface PipeableFunctor3C<F extends URIS3, E> {
  readonly map: <A, B>(f: (a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
}

Added in v2.2.0 v2.2.0中添加

PipeableFunctorWithIndex3C
PipeableFunctorWithIndex3C
(interface)   (界面)

Signature 签名

export interface PipeableFunctorWithIndex3C<F extends URIS3, I, E> extends PipeableFunctor3C<F, E> {
  readonly mapWithIndex: <A, B>(f: (i: I, a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
}

Added in v2.2.0 v2.2.0中添加

PipeableMonadThrow3C PipeableMonadThrow3C (interface)   (界面)

Signature 签名

export interface PipeableMonadThrow3C<F extends URIS3, E> {
  readonly fromOption: (onNone: LazyArg<E>) => <R, A>(ma: Option<A>) => Kind3<F, R, E, A>
  readonly fromEither: <R, A>(ma: Either<E, A>) => Kind3<F, R, E, A>
  readonly fromPredicate: {
    <A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <U>(a: A) => Kind3<F, U, E, B>
    <A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(a: A) => Kind3<F, R, E, A>
  }
  readonly filterOrElse: {
    <A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(
      ma: Kind3<F, R, E, A>
    ) => Kind3<F, R, E, B>
    <A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(ma: Kind3<F, R, E, A>) => Kind3<F, R, E, A>
  }
}

Added in v2.2.0 v2.2.0中添加

PipeableProfunctor3C PipeableProfunctor3C (interface)   (界面)

Signature 签名

export interface PipeableProfunctor3C<F extends URIS3, E> extends PipeableFunctor3C<F, E> {
  readonly promap: <R, A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: Kind3<F, R, E, A>) => Kind3<F, R, D, B>
}

Added in v2.2.0 v2.2.0中添加

PipeableSemigroupoid3C PipeableSemigroupoid3C (interface)   (界面)

Signature 签名

export interface PipeableSemigroupoid3C<F extends URIS3, E> {
  readonly compose: <R, A>(la: Kind3<F, R, E, A>) => <B>(ab: Kind3<F, R, A, B>) => Kind3<F, R, E, B>
}

Added in v2.2.0 v2.2.0中添加

pipe 管道

Use pipe from function module instead.
请改用 function 模块中的 pipe

Signature 签名

export declare const pipe: typeof pipeFromFunctionModule

Added in v2.0.0 v2.0.0 中添加

zone of death
死亡地带

PipeableAlt1 管道Alt1 (interface)   (界面)

Signature 签名

export interface PipeableAlt1<F extends URIS> {
  readonly alt: <A>(that: LazyArg<Kind<F, A>>) => (fa: Kind<F, A>) => Kind<F, A>
}

Added in v2.0.0 v2.0.0 中添加

PipeableAlt2C PipeableAlt2C (interface)   (界面)

Signature 签名

export interface PipeableAlt2C<F extends URIS2, E> {
  readonly alt: <A>(that: LazyArg<Kind2<F, E, A>>) => (fa: Kind2<F, E, A>) => Kind2<F, E, A>
}

Added in v2.0.0 v2.0.0 中添加

PipeableAlt2 管道Alt2 (interface)   (界面)

Signature 签名

export interface PipeableAlt2<F extends URIS2> {
  readonly alt: <E, A>(that: LazyArg<Kind2<F, E, A>>) => (fa: Kind2<F, E, A>) => Kind2<F, E, A>
}

Added in v2.0.0 v2.0.0 中添加

PipeableAlt3 管道Alt3 (interface)   (界面)

Signature 签名

export interface PipeableAlt3<F extends URIS3> {
  readonly alt: <R, E, A>(that: LazyArg<Kind3<F, R, E, A>>) => (fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>
}

Added in v2.0.0 v2.0.0 中添加

PipeableAlt4 管道Alt4 (interface)   (界面)

Signature 签名

export interface PipeableAlt4<F extends URIS4> {
  readonly alt: <S, R, E, A>(that: LazyArg<Kind4<F, S, R, E, A>>) => (fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>
}

Added in v2.0.0 v2.0.0 中添加

PipeableAlt 管道替代品 (interface)   (界面)

Signature 签名

export interface PipeableAlt<F> {
  readonly alt: <A>(that: LazyArg<HKT<F, A>>) => (fa: HKT<F, A>) => HKT<F, A>
}

Added in v2.0.0 v2.0.0 中添加

PipeableApply1 可管道应用1 (interface)   (界面)

Signature 签名

export interface PipeableApply1<F extends URIS> extends PipeableFunctor1<F> {
  readonly ap: <A>(fa: Kind<F, A>) => <B>(fab: Kind<F, (a: A) => B>) => Kind<F, B>
  readonly apFirst: <B>(fb: Kind<F, B>) => <A>(fa: Kind<F, A>) => Kind<F, A>
  readonly apSecond: <B>(fb: Kind<F, B>) => <A>(fa: Kind<F, A>) => Kind<F, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableApply2C PipeableApply2C (interface)   (界面)

Signature 签名

export interface PipeableApply2C<F extends URIS2, E> extends PipeableFunctor2C<F, E> {
  readonly ap: <A>(fa: Kind2<F, E, A>) => <B>(fab: Kind2<F, E, (a: A) => B>) => Kind2<F, E, B>
  readonly apFirst: <B>(fb: Kind2<F, E, B>) => <A>(fa: Kind2<F, E, A>) => Kind2<F, E, A>
  readonly apSecond: <B>(fb: Kind2<F, E, B>) => <A>(fa: Kind2<F, E, A>) => Kind2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableApply2 管道应用2 (interface)   (界面)

Signature 签名

export interface PipeableApply2<F extends URIS2> extends PipeableFunctor2<F> {
  readonly ap: <E, A>(fa: Kind2<F, E, A>) => <B>(fab: Kind2<F, E, (a: A) => B>) => Kind2<F, E, B>
  readonly apFirst: <E, B>(fb: Kind2<F, E, B>) => <A>(fa: Kind2<F, E, A>) => Kind2<F, E, A>
  readonly apSecond: <E, B>(fb: Kind2<F, E, B>) => <A>(fa: Kind2<F, E, A>) => Kind2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableApply3 可管道应用3 (interface)   (界面)

Signature 签名

export interface PipeableApply3<F extends URIS3> extends PipeableFunctor3<F> {
  readonly ap: <R, E, A>(fa: Kind3<F, R, E, A>) => <B>(fab: Kind3<F, R, E, (a: A) => B>) => Kind3<F, R, E, B>
  readonly apFirst: <R, E, B>(fb: Kind3<F, R, E, B>) => <A>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>
  readonly apSecond: <R, E, B>(fb: Kind3<F, R, E, B>) => <A>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableApply4 可管道应用4 (interface)   (界面)

Signature 签名

export interface PipeableApply4<F extends URIS4> extends PipeableFunctor4<F> {
  readonly ap: <S, R, E, A>(
    fa: Kind4<F, S, R, E, A>
  ) => <B>(fab: Kind4<F, S, R, E, (a: A) => B>) => Kind4<F, S, R, E, B>
  readonly apFirst: <S, R, E, B>(fb: Kind4<F, S, R, E, B>) => <A>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>
  readonly apSecond: <S, R, E, B>(fb: Kind4<F, S, R, E, B>) => <A>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableApply 可通过管道应用 (interface)   (界面)

Signature 签名

export interface PipeableApply<F> extends PipeableFunctor<F> {
  readonly ap: <A>(fa: HKT<F, A>) => <B>(fab: HKT<F, (a: A) => B>) => HKT<F, B>
  readonly apFirst: <B>(fb: HKT<F, B>) => <A>(fa: HKT<F, A>) => HKT<F, A>
  readonly apSecond: <B>(fb: HKT<F, B>) => <A>(fa: HKT<F, A>) => HKT<F, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableBifunctor2 PipeableBifunctor2 (interface)   (界面)

Signature 签名

export interface PipeableBifunctor2<F extends URIS2> {
  readonly bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: Kind2<F, E, A>) => Kind2<F, G, B>
  readonly mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: Kind2<F, E, A>) => Kind2<F, G, A>
}

Added in v2.0.0 v2.0.0 中添加

PipeableBifunctor3 PipeableBifunctor3 (interface)   (界面)

Signature 签名

export interface PipeableBifunctor3<F extends URIS3> {
  readonly bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, G, B>
  readonly mapLeft: <E, G>(f: (e: E) => G) => <R, A>(fa: Kind3<F, R, E, A>) => Kind3<F, R, G, A>
}

Added in v2.0.0 v2.0.0 中添加

PipeableBifunctor4 PipeableBifunctor4 (interface)   (界面)

Signature 签名

export interface PipeableBifunctor4<F extends URIS4> {
  readonly bimap: <E, G, A, B>(
    f: (e: E) => G,
    g: (a: A) => B
  ) => <S, R>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, G, B>
  readonly mapLeft: <E, G>(f: (e: E) => G) => <S, R, A>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, G, A>
}

Added in v2.0.0 v2.0.0 中添加

PipeableBifunctor PipeableBifunctor (interface)   (界面)

Signature 签名

export interface PipeableBifunctor<F> {
  readonly bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: HKT2<F, E, A>) => HKT2<F, G, B>
  readonly mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: HKT2<F, E, A>) => HKT2<F, G, A>
}

Added in v2.0.0 v2.0.0 中添加

PipeableChain1 管道链1 (interface)   (界面)

Signature 签名

export interface PipeableChain1<F extends URIS> extends PipeableApply1<F> {
  readonly chain: <A, B>(f: (a: A) => Kind<F, B>) => (ma: Kind<F, A>) => Kind<F, B>
  readonly chainFirst: <A, B>(f: (a: A) => Kind<F, B>) => (ma: Kind<F, A>) => Kind<F, A>
  readonly flatten: <A>(mma: Kind<F, Kind<F, A>>) => Kind<F, A>
}

Added in v2.0.0 v2.0.0 中添加

PipeableChain2C PipeableChain2C (interface)   (界面)

Signature 签名

export interface PipeableChain2C<F extends URIS2, E> extends PipeableApply2C<F, E> {
  readonly chain: <A, B>(f: (a: A) => Kind2<F, E, B>) => (ma: Kind2<F, E, A>) => Kind2<F, E, B>
  readonly chainFirst: <A, B>(f: (a: A) => Kind2<F, E, B>) => (ma: Kind2<F, E, A>) => Kind2<F, E, A>
  readonly flatten: <A>(mma: Kind2<F, E, Kind2<F, E, A>>) => Kind2<F, E, A>
}

Added in v2.0.0 v2.0.0 中添加

PipeableChain2 管道链2 (interface)   (界面)

Signature 签名

export interface PipeableChain2<F extends URIS2> extends PipeableApply2<F> {
  readonly chain: <E, A, B>(f: (a: A) => Kind2<F, E, B>) => (ma: Kind2<F, E, A>) => Kind2<F, E, B>
  readonly chainFirst: <E, A, B>(f: (a: A) => Kind2<F, E, B>) => (ma: Kind2<F, E, A>) => Kind2<F, E, A>
  readonly flatten: <E, A>(mma: Kind2<F, E, Kind2<F, E, A>>) => Kind2<F, E, A>
}

Added in v2.0.0 v2.0.0 中添加

PipeableChain3 管道链3 (interface)   (界面)

Signature 签名

export interface PipeableChain3<F extends URIS3> extends PipeableApply3<F> {
  readonly chain: <R, E, A, B>(f: (a: A) => Kind3<F, R, E, B>) => (ma: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
  readonly chainFirst: <R, E, A, B>(f: (a: A) => Kind3<F, R, E, B>) => (ma: Kind3<F, R, E, A>) => Kind3<F, R, E, A>
  readonly flatten: <R, E, A>(mma: Kind3<F, R, E, Kind3<F, R, E, A>>) => Kind3<F, R, E, A>
}

Added in v2.0.0 v2.0.0 中添加

PipeableChain4 管道链4 (interface)   (界面)

Signature 签名

export interface PipeableChain4<F extends URIS4> extends PipeableApply4<F> {
  readonly chain: <S, R, E, A, B>(
    f: (a: A) => Kind4<F, S, R, E, B>
  ) => (ma: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>
  readonly chainFirst: <S, R, E, A, B>(
    f: (a: A) => Kind4<F, S, R, E, B>
  ) => (ma: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>
  readonly flatten: <S, R, E, A>(mma: Kind4<F, S, R, E, Kind4<F, S, R, E, A>>) => Kind4<F, S, R, E, A>
}

Added in v2.0.0 v2.0.0 中添加

PipeableChain 管道链 (interface)   (界面)

Signature 签名

export interface PipeableChain<F> extends PipeableApply<F> {
  readonly chain: <A, B>(f: (a: A) => HKT<F, B>) => (ma: HKT<F, A>) => HKT<F, B>
  readonly chainFirst: <A, B>(f: (a: A) => HKT<F, B>) => (ma: HKT<F, A>) => HKT<F, A>
  readonly flatten: <A>(mma: HKT<F, HKT<F, A>>) => HKT<F, A>
}

Added in v2.0.0 v2.0.0 中添加

PipeableCompactable1 可管道压缩1 (interface)   (界面)

Signature 签名

export interface PipeableCompactable1<F extends URIS> {
  readonly compact: <A>(fa: Kind<F, Option<A>>) => Kind<F, A>
  readonly separate: <A, B>(fa: Kind<F, Either<A, B>>) => Separated<Kind<F, A>, Kind<F, B>>
}

Added in v2.0.0 v2.0.0 中添加

PipeableCompactable2C PipeableCompactable2C (interface)   (界面)

Signature 签名

export interface PipeableCompactable2C<F extends URIS2, E> {
  readonly compact: <A>(fa: Kind2<F, E, Option<A>>) => Kind2<F, E, A>
  readonly separate: <A, B>(fa: Kind2<F, E, Either<A, B>>) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

PipeableCompactable2 可管道压缩2 (interface)   (界面)

Signature 签名

export interface PipeableCompactable2<F extends URIS2> {
  readonly compact: <E, A>(fa: Kind2<F, E, Option<A>>) => Kind2<F, E, A>
  readonly separate: <E, A, B>(fa: Kind2<F, E, Either<A, B>>) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

PipeableCompactable3 可管道压缩3 (interface)   (界面)

Signature 签名

export interface PipeableCompactable3<F extends URIS3> {
  readonly compact: <R, E, A>(fa: Kind3<F, R, E, Option<A>>) => Kind3<F, R, E, A>
  readonly separate: <R, E, A, B>(fa: Kind3<F, R, E, Either<A, B>>) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

PipeableCompactable4 可管道压缩4 (interface)   (界面)

Signature 签名

export interface PipeableCompactable4<F extends URIS4> {
  readonly compact: <S, R, E, A>(fa: Kind4<F, S, R, E, Option<A>>) => Kind4<F, S, R, E, A>
  readonly separate: <S, R, E, A, B>(
    fa: Kind4<F, S, R, E, Either<A, B>>
  ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

PipeableCompactable 可管道压缩 (interface)   (界面)

Signature 签名

export interface PipeableCompactable<F> {
  readonly compact: <A>(fa: HKT<F, Option<A>>) => HKT<F, A>
  readonly separate: <A, B>(fa: HKT<F, Either<A, B>>) => Separated<HKT<F, A>, HKT<F, B>>
}

Added in v2.0.0 v2.0.0 中添加

PipeableContravariant1 Pipeable逆变1 (interface)   (界面)

Signature 签名

export interface PipeableContravariant1<F extends URIS> {
  readonly contramap: <A, B>(f: (b: B) => A) => (fa: Kind<F, A>) => Kind<F, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableContravariant2C Pipeable逆变2C (interface)   (界面)

Signature 签名

export interface PipeableContravariant2C<F extends URIS2, E> {
  readonly contramap: <A, B>(f: (b: B) => A) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableContravariant2 Pipeable逆变2 (interface)   (界面)

Signature 签名

export interface PipeableContravariant2<F extends URIS2> {
  readonly contramap: <A, B>(f: (b: B) => A) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableContravariant3 Pipeable逆变3 (interface)   (界面)

Signature 签名

export interface PipeableContravariant3<F extends URIS3> {
  readonly contramap: <A, B>(f: (b: B) => A) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableContravariant4 Pipeable逆变4 (interface)   (界面)

Signature 签名

export interface PipeableContravariant4<F extends URIS4> {
  readonly contramap: <A, B>(f: (b: B) => A) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableContravariant 可管道逆变 (interface)   (界面)

Signature 签名

export interface PipeableContravariant<F> {
  readonly contramap: <A, B>(f: (b: B) => A) => (fa: HKT<F, A>) => HKT<F, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableExtend1 管道扩展1 (interface)   (界面)

Signature 签名

export interface PipeableExtend1<F extends URIS> extends PipeableFunctor1<F> {
  readonly extend: <A, B>(f: (wa: Kind<F, A>) => B) => (wa: Kind<F, A>) => Kind<F, B>
  readonly duplicate: <A>(wa: Kind<F, A>) => Kind<F, Kind<F, A>>
}

Added in v2.0.0 v2.0.0 中添加

PipeableExtend2C PipeableExtend2C (interface)   (界面)

Signature 签名

export interface PipeableExtend2C<F extends URIS2, E> extends PipeableFunctor2C<F, E> {
  readonly extend: <A, B>(f: (wa: Kind2<F, E, A>) => B) => (wa: Kind2<F, E, A>) => Kind2<F, E, B>
  readonly duplicate: <A>(wa: Kind2<F, E, A>) => Kind2<F, E, Kind2<F, E, A>>
}

Added in v2.0.0 v2.0.0 中添加

PipeableExtend2 管道扩展2 (interface)   (界面)

Signature 签名

export interface PipeableExtend2<F extends URIS2> extends PipeableFunctor2<F> {
  readonly extend: <E, A, B>(f: (wa: Kind2<F, E, A>) => B) => (wa: Kind2<F, E, A>) => Kind2<F, E, B>
  readonly duplicate: <E, A>(wa: Kind2<F, E, A>) => Kind2<F, E, Kind2<F, E, A>>
}

Added in v2.0.0 v2.0.0 中添加

PipeableExtend3 管道扩展3 (interface)   (界面)

Signature 签名

export interface PipeableExtend3<F extends URIS3> extends PipeableFunctor3<F> {
  readonly extend: <R, E, A, B>(f: (wa: Kind3<F, R, E, A>) => B) => (wa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
  readonly duplicate: <R, E, A>(wa: Kind3<F, R, E, A>) => Kind3<F, R, E, Kind3<F, R, E, A>>
}

Added in v2.0.0 v2.0.0 中添加

PipeableExtend4 管道扩展4 (interface)   (界面)

Signature 签名

export interface PipeableExtend4<F extends URIS4> extends PipeableFunctor4<F> {
  readonly extend: <S, R, E, A, B>(
    f: (wa: Kind4<F, S, R, E, A>) => B
  ) => (wa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>
  readonly duplicate: <S, R, E, A>(wa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, Kind4<F, S, R, E, A>>
}

Added in v2.0.0 v2.0.0 中添加

PipeableExtend 管道扩展 (interface)   (界面)

Signature 签名

export interface PipeableExtend<F> extends PipeableFunctor<F> {
  readonly extend: <A, B>(f: (wa: HKT<F, A>) => B) => (wa: HKT<F, A>) => HKT<F, B>
  readonly duplicate: <A>(wa: HKT<F, A>) => HKT<F, HKT<F, A>>
}

Added in v2.0.0 v2.0.0 中添加

PipeableFilterable1 可管道可过滤1 (interface)   (界面)

Signature 签名

export interface PipeableFilterable1<F extends URIS> extends PipeableCompactable1<F> {
  readonly filter: {
    <A, B extends A>(refinement: Refinement<A, B>): (fa: Kind<F, A>) => Kind<F, B>
    <A>(predicate: Predicate<A>): (fa: Kind<F, A>) => Kind<F, A>
  }
  readonly filterMap: <A, B>(f: (a: A) => Option<B>) => (fa: Kind<F, A>) => Kind<F, B>
  readonly partition: {
    <A, B extends A>(refinement: Refinement<A, B>): (fa: Kind<F, A>) => Separated<Kind<F, A>, Kind<F, B>>
    <A>(predicate: Predicate<A>): (fa: Kind<F, A>) => Separated<Kind<F, A>, Kind<F, A>>
  }
  readonly partitionMap: <A, B, C>(f: (a: A) => Either<B, C>) => (fa: Kind<F, A>) => Separated<Kind<F, B>, Kind<F, C>>
}

Added in v2.0.0 v2.0.0 中添加

PipeableFilterable2C PipeableFilterable2C (interface)   (界面)

Signature 签名

export interface PipeableFilterable2C<F extends URIS2, E> extends PipeableCompactable2C<F, E> {
  readonly filter: {
    <A, B extends A>(refinement: Refinement<A, B>): (fa: Kind2<F, E, A>) => Kind2<F, E, B>
    <A>(predicate: Predicate<A>): (fa: Kind2<F, E, A>) => Kind2<F, E, A>
  }
  readonly filterMap: <A, B>(f: (a: A) => Option<B>) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>
  readonly partition: {
    <A, B extends A>(refinement: Refinement<A, B>): (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>
    <A>(predicate: Predicate<A>): (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, A>>
  }
  readonly partitionMap: <A, B, C>(
    f: (a: A) => Either<B, C>
  ) => (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>
}

Added in v2.0.0 v2.0.0 中添加

PipeableFilterable2 可管道过滤2 (interface)   (界面)

Signature 签名

export interface PipeableFilterable2<F extends URIS2> extends PipeableCompactable2<F> {
  readonly filter: {
    <A, B extends A>(refinement: Refinement<A, B>): <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>
    <A>(predicate: Predicate<A>): <E>(fa: Kind2<F, E, A>) => Kind2<F, E, A>
  }
  readonly filterMap: <A, B>(f: (a: A) => Option<B>) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>
  readonly partition: {
    <A, B extends A>(refinement: Refinement<A, B>): <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>
    <A>(predicate: Predicate<A>): <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, A>>
  }
  readonly partitionMap: <A, B, C>(
    f: (a: A) => Either<B, C>
  ) => <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>
}

Added in v2.0.0 v2.0.0 中添加

PipeableFilterable3 可管道可过滤3 (interface)   (界面)

Signature 签名

export interface PipeableFilterable3<F extends URIS3> extends PipeableCompactable3<F> {
  readonly filter: {
    <A, B extends A>(refinement: Refinement<A, B>): <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
    <A>(predicate: Predicate<A>): <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>
  }
  readonly filterMap: <A, B>(f: (a: A) => Option<B>) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>
  readonly partition: {
    <A, B extends A>(refinement: Refinement<A, B>): <R, E>(
      fa: Kind3<F, R, E, A>
    ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>
    <A>(predicate: Predicate<A>): <R, E>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>
  }
  readonly partitionMap: <A, B, C>(
    f: (a: A) => Either<B, C>
  ) => <R, E>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>
}

Added in v2.0.0 v2.0.0 中添加

PipeableFilterable4 可管道可过滤4 (interface)   (界面)

Signature 签名

export interface PipeableFilterable4<F extends URIS4> extends PipeableCompactable4<F> {
  readonly filter: {
    <A, B extends A>(refinement: Refinement<A, B>): <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>
    <A>(predicate: Predicate<A>): <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>
  }
  readonly filterMap: <A, B>(f: (a: A) => Option<B>) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>
  readonly partition: {
    <A, B extends A>(refinement: Refinement<A, B>): <S, R, E>(
      fa: Kind4<F, S, R, E, A>
    ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, B>>
    <A>(predicate: Predicate<A>): <S, R, E>(
      fa: Kind4<F, S, R, E, A>
    ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, A>>
  }
  readonly partitionMap: <A, B, C>(
    f: (a: A) => Either<B, C>
  ) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Separated<Kind4<F, S, R, E, B>, Kind4<F, S, R, E, C>>
}

Added in v2.0.0 v2.0.0 中添加

PipeableFilterableWithIndex1
PipeableFilterableWithIndex1
(interface)   (界面)

Signature 签名

export interface PipeableFilterableWithIndex1<F extends URIS, I> extends PipeableFilterable1<F> {
  readonly filterWithIndex: {
    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): (fa: Kind<F, A>) => Kind<F, B>
    <A>(predicateWithIndex: PredicateWithIndex<I, A>): (fa: Kind<F, A>) => Kind<F, A>
  }
  readonly filterMapWithIndex: <A, B>(f: (i: I, a: A) => Option<B>) => (fa: Kind<F, A>) => Kind<F, B>
  readonly partitionWithIndex: {
    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): (
      fa: Kind<F, A>
    ) => Separated<Kind<F, A>, Kind<F, B>>
    <A>(predicateWithIndex: PredicateWithIndex<I, A>): (fa: Kind<F, A>) => Separated<Kind<F, A>, Kind<F, A>>
  }
  readonly partitionMapWithIndex: <A, B, C>(
    f: (i: I, a: A) => Either<B, C>
  ) => (fa: Kind<F, A>) => Separated<Kind<F, B>, Kind<F, C>>
}

Added in v2.0.0 v2.0.0 中添加

PipeableFilterableWithIndex2C
PipeableFilterableWithIndex2C
(interface)   (界面)

Signature 签名

export interface PipeableFilterableWithIndex2C<F extends URIS2, I, E> extends PipeableFilterable2C<F, E> {
  readonly filterWithIndex: {
    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): (fa: Kind2<F, E, A>) => Kind2<F, E, B>
    <A>(predicateWithIndex: PredicateWithIndex<I, A>): (fa: Kind2<F, E, A>) => Kind2<F, E, A>
  }
  readonly filterMapWithIndex: <A, B>(f: (i: I, a: A) => Option<B>) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>
  readonly partitionWithIndex: {
    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): (
      fa: Kind2<F, E, A>
    ) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>
    <A>(predicateWithIndex: PredicateWithIndex<I, A>): (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, A>>
  }
  readonly partitionMapWithIndex: <A, B, C>(
    f: (i: I, a: A) => Either<B, C>
  ) => (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>
}

Added in v2.0.0 v2.0.0 中添加

PipeableFilterableWithIndex2
PipeableFilterableWithIndex2
(interface)   (界面)

Signature 签名

export interface PipeableFilterableWithIndex2<F extends URIS2, I> extends PipeableFilterable2<F> {
  readonly filterWithIndex: {
    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>
    <A>(predicateWithIndex: PredicateWithIndex<I, A>): <E>(fa: Kind2<F, E, A>) => Kind2<F, E, A>
  }
  readonly filterMapWithIndex: <A, B>(f: (i: I, a: A) => Option<B>) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>
  readonly partitionWithIndex: {
    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): <E>(
      fa: Kind2<F, E, A>
    ) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>
    <A>(predicateWithIndex: PredicateWithIndex<I, A>): <E>(
      fa: Kind2<F, E, A>
    ) => Separated<Kind2<F, E, A>, Kind2<F, E, A>>
  }
  readonly partitionMapWithIndex: <A, B, C>(
    f: (i: I, a: A) => Either<B, C>
  ) => <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>
}

Added in v2.0.0 v2.0.0 中添加

PipeableFilterableWithIndex3
PipeableFilterableWithIndex3
(interface)   (界面)

Signature 签名

export interface PipeableFilterableWithIndex3<F extends URIS3, I> extends PipeableFilterable3<F> {
  readonly filterWithIndex: {
    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): <R, E>(
      fa: Kind3<F, R, E, A>
    ) => Kind3<F, R, E, B>
    <A>(predicateWithIndex: PredicateWithIndex<I, A>): <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>
  }
  readonly filterMapWithIndex: <A, B>(
    f: (i: I, a: A) => Option<B>
  ) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>
  readonly partitionWithIndex: {
    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): <R, E>(
      fa: Kind3<F, R, E, A>
    ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>
    <A>(predicateWithIndex: PredicateWithIndex<I, A>): <R, E>(
      fa: Kind3<F, R, E, A>
    ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>
  }
  readonly partitionMapWithIndex: <A, B, C>(
    f: (i: I, a: A) => Either<B, C>
  ) => <R, E>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>
}

Added in v2.0.0 v2.0.0 中添加

PipeableFilterableWithIndex4
PipeableFilterableWithIndex4
(interface)   (界面)

Signature 签名

export interface PipeableFilterableWithIndex4<F extends URIS4, I> extends PipeableFilterable4<F> {
  readonly filterWithIndex: {
    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): <S, R, E>(
      fa: Kind4<F, S, R, E, A>
    ) => Kind4<F, S, R, E, B>
    <A>(predicateWithIndex: PredicateWithIndex<I, A>): <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>
  }
  readonly filterMapWithIndex: <A, B>(
    f: (i: I, a: A) => Option<B>
  ) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>
  readonly partitionWithIndex: {
    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): <S, R, E>(
      fa: Kind4<F, S, R, E, A>
    ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, B>>
    <A>(predicateWithIndex: PredicateWithIndex<I, A>): <S, R, E>(
      fa: Kind4<F, S, R, E, A>
    ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, A>>
  }
  readonly partitionMapWithIndex: <A, B, C>(
    f: (i: I, a: A) => Either<B, C>
  ) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Separated<Kind4<F, S, R, E, B>, Kind4<F, S, R, E, C>>
}

Added in v2.0.0 v2.0.0 中添加

PipeableFilterableWithIndex
可管道过滤带索引
(interface)   (界面)

Signature 签名

export interface PipeableFilterableWithIndex<F, I> extends PipeableFilterable<F> {
  readonly filterWithIndex: {
    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): (fa: HKT<F, A>) => HKT<F, B>
    <A>(predicateWithIndex: PredicateWithIndex<I, A>): (fa: HKT<F, A>) => HKT<F, A>
  }
  readonly filterMapWithIndex: <A, B>(f: (i: I, a: A) => Option<B>) => (fa: HKT<F, A>) => HKT<F, B>
  readonly partitionWithIndex: {
    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): (
      fa: HKT<F, A>
    ) => Separated<HKT<F, A>, HKT<F, B>>
    <A>(predicateWithIndex: PredicateWithIndex<I, A>): (fa: HKT<F, A>) => Separated<HKT<F, A>, HKT<F, A>>
  }
  readonly partitionMapWithIndex: <A, B, C>(
    f: (i: I, a: A) => Either<B, C>
  ) => (fa: HKT<F, A>) => Separated<HKT<F, B>, HKT<F, C>>
}

Added in v2.0.0 v2.0.0 中添加

PipeableFilterable 可管道可过滤 (interface)   (界面)

Signature 签名

export interface PipeableFilterable<F> extends PipeableCompactable<F> {
  readonly filter: {
    <A, B extends A>(refinement: Refinement<A, B>): (fa: HKT<F, A>) => HKT<F, B>
    <A>(predicate: Predicate<A>): (fa: HKT<F, A>) => HKT<F, A>
  }
  readonly filterMap: <A, B>(f: (a: A) => Option<B>) => (fa: HKT<F, A>) => HKT<F, B>
  readonly partition: {
    <A, B extends A>(refinement: Refinement<A, B>): (fa: HKT<F, A>) => Separated<HKT<F, A>, HKT<F, B>>
    <A>(predicate: Predicate<A>): (fa: HKT<F, A>) => Separated<HKT<F, A>, HKT<F, A>>
  }
  readonly partitionMap: <A, B, C>(f: (a: A) => Either<B, C>) => (fa: HKT<F, A>) => Separated<HKT<F, B>, HKT<F, C>>
}

Added in v2.0.0 v2.0.0 中添加

PipeableFoldable1 可管道可折叠1 (interface)   (界面)

Signature 签名

export interface PipeableFoldable1<F extends URIS> {
  readonly reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: Kind<F, A>) => B
  readonly foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: Kind<F, A>) => M
  readonly reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: Kind<F, A>) => B
}

Added in v2.0.0 v2.0.0 中添加

PipeableFoldable2C 可管道式可折叠2C (interface)   (界面)

Signature 签名

export interface PipeableFoldable2C<F extends URIS2, E> {
  readonly reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: Kind2<F, E, A>) => B
  readonly foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: Kind2<F, E, A>) => M
  readonly reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: Kind2<F, E, A>) => B
}

Added in v2.0.0 v2.0.0 中添加

PipeableFoldable2 可管道可折叠2 (interface)   (界面)

Signature 签名

export interface PipeableFoldable2<F extends URIS2> {
  readonly reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <E>(fa: Kind2<F, E, A>) => B
  readonly foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <E>(fa: Kind2<F, E, A>) => M
  readonly reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <E>(fa: Kind2<F, E, A>) => B
}

Added in v2.0.0 v2.0.0 中添加

PipeableFoldable3 可管道可折叠3 (interface)   (界面)

Signature 签名

export interface PipeableFoldable3<F extends URIS3> {
  readonly reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <R, E>(fa: Kind3<F, R, E, A>) => B
  readonly foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <R, E>(fa: Kind3<F, R, E, A>) => M
  readonly reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <R, E>(fa: Kind3<F, R, E, A>) => B
}

Added in v2.0.0 v2.0.0 中添加

PipeableFoldable4 可管道可折叠4 (interface)   (界面)

Signature 签名

export interface PipeableFoldable4<F extends URIS4> {
  readonly reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => B
  readonly foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => M
  readonly reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => B
}

Added in v2.0.0 v2.0.0 中添加

PipeableFoldableWithIndex1
PipeableFoldableWithIndex1
(interface)   (界面)

Signature 签名

export interface PipeableFoldableWithIndex1<F extends URIS, I> extends PipeableFoldable1<F> {
  readonly reduceWithIndex: <A, B>(b: B, f: (i: I, b: B, a: A) => B) => (fa: Kind<F, A>) => B
  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => (fa: Kind<F, A>) => M
  readonly reduceRightWithIndex: <A, B>(b: B, f: (i: I, a: A, b: B) => B) => (fa: Kind<F, A>) => B
}

Added in v2.0.0 v2.0.0 中添加

PipeableFoldableWithIndex2C
PipeableFoldableWithIndex2C
(interface)   (界面)

Signature 签名

export interface PipeableFoldableWithIndex2C<F extends URIS2, I, E> extends PipeableFoldable2C<F, E> {
  readonly reduceWithIndex: <A, B>(b: B, f: (i: I, b: B, a: A) => B) => (fa: Kind2<F, E, A>) => B
  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => (fa: Kind2<F, E, A>) => M
  readonly reduceRightWithIndex: <A, B>(b: B, f: (i: I, a: A, b: B) => B) => (fa: Kind2<F, E, A>) => B
}

Added in v2.0.0 v2.0.0 中添加

PipeableFoldableWithIndex2
PipeableFoldableWithIndex2
(interface)   (界面)

Signature 签名

export interface PipeableFoldableWithIndex2<F extends URIS2, I> extends PipeableFoldable2<F> {
  readonly reduceWithIndex: <A, B>(b: B, f: (i: I, b: B, a: A) => B) => <E>(fa: Kind2<F, E, A>) => B
  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => <E>(fa: Kind2<F, E, A>) => M
  readonly reduceRightWithIndex: <A, B>(b: B, f: (i: I, a: A, b: B) => B) => <E>(fa: Kind2<F, E, A>) => B
}

Added in v2.0.0 v2.0.0 中添加

PipeableFoldableWithIndex3
PipeableFoldableWithIndex3
(interface)   (界面)

Signature 签名

export interface PipeableFoldableWithIndex3<F extends URIS3, I> extends PipeableFoldable3<F> {
  readonly reduceWithIndex: <A, B>(b: B, f: (i: I, b: B, a: A) => B) => <R, E>(fa: Kind3<F, R, E, A>) => B
  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => <R, E>(fa: Kind3<F, R, E, A>) => M
  readonly reduceRightWithIndex: <A, B>(b: B, f: (i: I, a: A, b: B) => B) => <R, E>(fa: Kind3<F, R, E, A>) => B
}

Added in v2.0.0 v2.0.0 中添加

PipeableFoldableWithIndex4
PipeableFoldableWithIndex4
(interface)   (界面)

Signature 签名

export interface PipeableFoldableWithIndex4<F extends URIS4, I> extends PipeableFoldable4<F> {
  readonly reduceWithIndex: <A, B>(b: B, f: (i: I, b: B, a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => B
  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => M
  readonly reduceRightWithIndex: <A, B>(b: B, f: (i: I, a: A, b: B) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => B
}

Added in v2.0.0 v2.0.0 中添加

PipeableFoldableWithIndex
可折叠带索引的管道
(interface)   (界面)

Signature 签名

export interface PipeableFoldableWithIndex<F, I> extends PipeableFoldable<F> {
  readonly reduceWithIndex: <A, B>(b: B, f: (i: I, b: B, a: A) => B) => (fa: HKT<F, A>) => B
  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => (fa: HKT<F, A>) => M
  readonly reduceRightWithIndex: <A, B>(b: B, f: (i: I, a: A, b: B) => B) => (fa: HKT<F, A>) => B
}

Added in v2.0.0 v2.0.0 中添加

PipeableFoldable 可管道式可折叠 (interface)   (界面)

Signature 签名

export interface PipeableFoldable<F> {
  readonly reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: HKT<F, A>) => B
  readonly foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: HKT<F, A>) => M
  readonly reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: HKT<F, A>) => B
}

Added in v2.0.0 v2.0.0 中添加

PipeableFunctor1 PipeableFunctor1 (interface)   (界面)

Signature 签名

export interface PipeableFunctor1<F extends URIS> {
  readonly map: <A, B>(f: (a: A) => B) => (fa: Kind<F, A>) => Kind<F, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableFunctor2C PipeableFunctor2C (interface)   (界面)

Signature 签名

export interface PipeableFunctor2C<F extends URIS2, E> {
  readonly map: <A, B>(f: (a: A) => B) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableFunctor2 PipeableFunctor2 (interface)   (界面)

Signature 签名

export interface PipeableFunctor2<F extends URIS2> {
  readonly map: <A, B>(f: (a: A) => B) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableFunctor3 PipeableFunctor3 (interface)   (界面)

Signature 签名

export interface PipeableFunctor3<F extends URIS3> {
  readonly map: <A, B>(f: (a: A) => B) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableFunctor4 PipeableFunctor4 (interface)   (界面)

Signature 签名

export interface PipeableFunctor4<F extends URIS4> {
  readonly map: <A, B>(f: (a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableFunctorWithIndex1
PipeableFunctorWithIndex1
(interface)   (界面)

Signature 签名

export interface PipeableFunctorWithIndex1<F extends URIS, I> extends PipeableFunctor1<F> {
  readonly mapWithIndex: <A, B>(f: (i: I, a: A) => B) => (fa: Kind<F, A>) => Kind<F, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableFunctorWithIndex2C
PipeableFunctorWithIndex2C
(interface)   (界面)

Signature 签名

export interface PipeableFunctorWithIndex2C<F extends URIS2, I, E> extends PipeableFunctor2C<F, E> {
  readonly mapWithIndex: <A, B>(f: (i: I, a: A) => B) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableFunctorWithIndex2
PipeableFunctorWithIndex2
(interface)   (界面)

Signature 签名

export interface PipeableFunctorWithIndex2<F extends URIS2, I> extends PipeableFunctor2<F> {
  readonly mapWithIndex: <A, B>(f: (i: I, a: A) => B) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableFunctorWithIndex3
PipeableFunctorWithIndex3
(interface)   (界面)

Signature 签名

export interface PipeableFunctorWithIndex3<F extends URIS3, I> extends PipeableFunctor3<F> {
  readonly mapWithIndex: <A, B>(f: (i: I, a: A) => B) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableFunctorWithIndex4
PipeableFunctorWithIndex4
(interface)   (界面)

Signature 签名

export interface PipeableFunctorWithIndex4<F extends URIS4, I> extends PipeableFunctor4<F> {
  readonly mapWithIndex: <A, B>(f: (i: I, a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableFunctorWithIndex
带索引的 PipeableFunctor
(interface)   (界面)

Signature 签名

export interface PipeableFunctorWithIndex<F, I> extends PipeableFunctor<F> {
  readonly mapWithIndex: <A, B>(f: (i: I, a: A) => B) => (fa: HKT<F, A>) => HKT<F, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableFunctor 管道函子 (interface)   (界面)

Signature 签名

export interface PipeableFunctor<F> {
  readonly map: <A, B>(f: (a: A) => B) => (fa: HKT<F, A>) => HKT<F, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableMonadThrow1 PipeableMonadThrow1 (interface)   (界面)

Signature 签名

export interface PipeableMonadThrow1<F extends URIS> {
  readonly fromOption: <E>(onNone: LazyArg<E>) => <A>(ma: Option<A>) => Kind<F, A>
  readonly fromEither: <E, A>(ma: Either<E, A>) => Kind<F, A>
  readonly fromPredicate: {
    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => Kind<F, B>
    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => Kind<F, A>
  }
  readonly filterOrElse: {
    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: Kind<F, A>) => Kind<F, B>
    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: Kind<F, A>) => Kind<F, A>
  }
}

Added in v2.0.0 v2.0.0 中添加

PipeableMonadThrow2C PipeableMonadThrow2C (interface)   (界面)

Signature 签名

export interface PipeableMonadThrow2C<F extends URIS2, E> {
  readonly fromOption: (onNone: LazyArg<E>) => <A>(ma: Option<A>) => Kind2<F, E, A>
  readonly fromEither: <A>(ma: Either<E, A>) => Kind2<F, E, A>
  readonly fromPredicate: {
    <A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => Kind2<F, E, B>
    <A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => Kind2<F, E, A>
  }
  readonly filterOrElse: {
    <A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: Kind2<F, E, A>) => Kind2<F, E, B>
    <A>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: Kind2<F, E, A>) => Kind2<F, E, A>
  }
}

Added in v2.0.0 v2.0.0 中添加

PipeableMonadThrow2 PipeableMonadThrow2 (interface)   (界面)

Signature 签名

export interface PipeableMonadThrow2<F extends URIS2> {
  readonly fromOption: <E>(onNone: LazyArg<E>) => <A>(ma: Option<A>) => Kind2<F, E, A>
  readonly fromEither: <E, A>(ma: Either<E, A>) => Kind2<F, E, A>
  readonly fromPredicate: {
    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => Kind2<F, E, B>
    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => Kind2<F, E, A>
  }
  readonly filterOrElse: {
    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: Kind2<F, E, A>) => Kind2<F, E, B>
    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: Kind2<F, E, A>) => Kind2<F, E, A>
  }
}

Added in v2.0.0 v2.0.0 中添加

PipeableMonadThrow3 PipeableMonadThrow3 (interface)   (界面)

Signature 签名

export interface PipeableMonadThrow3<F extends URIS3> {
  readonly fromOption: <E>(onNone: LazyArg<E>) => <R, A>(ma: Option<A>) => Kind3<F, R, E, A>
  readonly fromEither: <R, E, A>(ma: Either<E, A>) => Kind3<F, R, E, A>
  readonly fromPredicate: {
    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <U>(a: A) => Kind3<F, U, E, B>
    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(a: A) => Kind3<F, R, E, A>
  }
  readonly filterOrElse: {
    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(
      ma: Kind3<F, R, E, A>
    ) => Kind3<F, R, E, B>
    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(ma: Kind3<F, R, E, A>) => Kind3<F, R, E, A>
  }
}

Added in v2.0.0 v2.0.0 中添加

PipeableMonadThrow4 PipeableMonadThrow4 (interface)   (界面)

Signature 签名

export interface PipeableMonadThrow4<F extends URIS4> {
  readonly fromOption: <E>(onNone: LazyArg<E>) => <S, R, A>(ma: Option<A>) => Kind4<F, S, R, E, A>
  readonly fromEither: <S, R, E, A>(ma: Either<E, A>) => Kind4<F, S, R, E, A>
  readonly fromPredicate: {
    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <S, R>(a: A) => Kind4<F, S, R, E, B>
    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R>(a: A) => Kind4<F, S, R, E, A>
  }
  readonly filterOrElse: {
    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <S, R>(
      ma: Kind4<F, S, R, E, A>
    ) => Kind4<F, S, R, E, B>
    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R>(ma: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>
  }
}

Added in v2.0.0 v2.0.0 中添加

PipeableMonadThrow PipeableMonad抛出 (interface)   (界面)

Signature 签名

export interface PipeableMonadThrow<F> {
  readonly fromOption: <E>(onNone: LazyArg<E>) => <A>(ma: Option<A>) => HKT<F, A>
  readonly fromEither: <E, A>(ma: Either<E, A>) => HKT<F, A>
  readonly fromPredicate: {
    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => HKT<F, B>
    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => HKT<F, A>
  }
  readonly filterOrElse: {
    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: HKT<F, A>) => HKT<F, B>
    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: HKT<F, A>) => HKT<F, A>
  }
}

Added in v2.0.0 v2.0.0 中添加

PipeableProfunctor2C PipeableProfunctor2C (interface)   (界面)

Signature 签名

export interface PipeableProfunctor2C<F extends URIS2, E> extends PipeableFunctor2C<F, E> {
  readonly promap: <A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: Kind2<F, E, A>) => Kind2<F, D, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableProfunctor2 PipeableProfunctor2 (interface)   (界面)

Signature 签名

export interface PipeableProfunctor2<F extends URIS2> extends PipeableFunctor2<F> {
  readonly promap: <E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: Kind2<F, E, A>) => Kind2<F, D, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableProfunctor3 PipeableProfunctor3 (interface)   (界面)

Signature 签名

export interface PipeableProfunctor3<F extends URIS3> extends PipeableFunctor3<F> {
  readonly promap: <R, E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: Kind3<F, R, E, A>) => Kind3<F, R, D, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableProfunctor4 PipeableProfunctor4 (interface)   (界面)

Signature 签名

export interface PipeableProfunctor4<F extends URIS4> extends PipeableFunctor4<F> {
  readonly promap: <S, R, E, A, D, B>(
    f: (d: D) => E,
    g: (a: A) => B
  ) => (fbc: Kind4<F, S, R, E, A>) => Kind4<F, S, R, D, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableProfunctor 管道连接器 (interface)   (界面)

Signature 签名

export interface PipeableProfunctor<F> {
  readonly promap: <E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: HKT2<F, E, A>) => HKT2<F, D, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableSemigroupoid2C PipeableSemigroupoid2C (interface)   (界面)

Signature 签名

export interface PipeableSemigroupoid2C<F extends URIS2, E> {
  readonly compose: <A>(la: Kind2<F, E, A>) => <B>(ab: Kind2<F, A, B>) => Kind2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableSemigroupoid2 PipeableSemigroupoid2 (interface)   (界面)

Signature 签名

export interface PipeableSemigroupoid2<F extends URIS2> {
  readonly compose: <E, A>(la: Kind2<F, E, A>) => <B>(ab: Kind2<F, A, B>) => Kind2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableSemigroupoid3 PipeableSemigroupoid3 (interface)   (界面)

Signature 签名

export interface PipeableSemigroupoid3<F extends URIS3> {
  readonly compose: <R, E, A>(la: Kind3<F, R, E, A>) => <B>(ab: Kind3<F, R, A, B>) => Kind3<F, R, E, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableSemigroupoid4 PipeableSemigroupoid4 (interface)   (界面)

Signature 签名

export interface PipeableSemigroupoid4<F extends URIS4> {
  readonly compose: <S, R, E, A>(la: Kind4<F, S, R, E, A>) => <B>(ab: Kind4<F, S, R, A, B>) => Kind4<F, S, R, E, B>
}

Added in v2.0.0 v2.0.0 中添加

PipeableSemigroupoid 管道半群 (interface)   (界面)

Signature 签名

export interface PipeableSemigroupoid<F> {
  readonly compose: <E, A>(la: HKT2<F, E, A>) => <B>(ab: HKT2<F, A, B>) => HKT2<F, E, B>
}

Added in v2.0.0 v2.0.0 中添加

pipeable 可管道化的

Signature 签名

export declare function pipeable<F extends URIS4, I>(
  I: { readonly URI: F } & I
): (I extends Chain4<F>
  ? PipeableChain4<F>
  : I extends Apply4<F>
  ? PipeableApply4<F>
  : I extends Functor4<F>
  ? PipeableFunctor4<F>
  : {}) &
  (I extends Contravariant4<F> ? PipeableContravariant4<F> : {}) &
  (I extends FunctorWithIndex4<F, infer Ix> ? PipeableFunctorWithIndex4<F, Ix> : {}) &
  (I extends Bifunctor4<F> ? PipeableBifunctor4<F> : {}) &
  (I extends Extend4<F> ? PipeableExtend4<F> : {}) &
  (I extends FoldableWithIndex4<F, infer Ix>
    ? PipeableFoldableWithIndex4<F, Ix>
    : I extends Foldable4<F>
    ? PipeableFoldable4<F>
    : {}) &
  (I extends Alt4<F> ? PipeableAlt4<F> : {}) &
  (I extends FilterableWithIndex4<F, infer Ix>
    ? PipeableFilterableWithIndex4<F, Ix>
    : I extends Filterable4<F>
    ? PipeableFilterable4<F>
    : I extends Compactable4<F>
    ? PipeableCompactable4<F>
    : {}) &
  (I extends Profunctor4<F> ? PipeableProfunctor4<F> : {}) &
  (I extends Semigroupoid4<F> ? PipeableSemigroupoid4<F> : {}) &
  (I extends MonadThrow4<F> ? PipeableMonadThrow4<F> : {})
export declare function pipeable<F extends URIS3, I>(
  I: { readonly URI: F } & I
): (I extends Chain3<F>
  ? PipeableChain3<F>
  : I extends Apply3<F>
  ? PipeableApply3<F>
  : I extends Functor3<F>
  ? PipeableFunctor3<F>
  : {}) &
  (I extends Contravariant3<F> ? PipeableContravariant3<F> : {}) &
  (I extends FunctorWithIndex3<F, infer Ix> ? PipeableFunctorWithIndex3<F, Ix> : {}) &
  (I extends Bifunctor3<F> ? PipeableBifunctor3<F> : {}) &
  (I extends Extend3<F> ? PipeableExtend3<F> : {}) &
  (I extends FoldableWithIndex3<F, infer Ix>
    ? PipeableFoldableWithIndex3<F, Ix>
    : I extends Foldable3<F>
    ? PipeableFoldable3<F>
    : {}) &
  (I extends Alt3<F> ? PipeableAlt3<F> : {}) &
  (I extends FilterableWithIndex3<F, infer Ix>
    ? PipeableFilterableWithIndex3<F, Ix>
    : I extends Filterable3<F>
    ? PipeableFilterable3<F>
    : I extends Compactable3<F>
    ? PipeableCompactable3<F>
    : {}) &
  (I extends Profunctor3<F> ? PipeableProfunctor3<F> : {}) &
  (I extends Semigroupoid3<F> ? PipeableSemigroupoid3<F> : {}) &
  (I extends MonadThrow3<F> ? PipeableMonadThrow3<F> : {})
export declare function pipeable<F extends URIS3, I, E>(
  I: { readonly URI: F } & I
): (I extends Chain3C<F, E>
  ? PipeableChain3C<F, E>
  : I extends Apply3C<F, E>
  ? PipeableApply3C<F, E>
  : I extends Functor3C<F, E>
  ? PipeableFunctor3C<F, E>
  : {}) &
  (I extends Contravariant3C<F, E> ? PipeableContravariant3C<F, E> : {}) &
  (I extends FunctorWithIndex3C<F, infer Ix, E> ? PipeableFunctorWithIndex3C<F, Ix, E> : {}) &
  (I extends Bifunctor3C<F, E> ? PipeableBifunctor3C<F, E> : {}) &
  (I extends Extend3C<F, E> ? PipeableExtend3C<F, E> : {}) &
  (I extends FoldableWithIndex3C<F, infer Ix, E>
    ? PipeableFoldableWithIndex3C<F, Ix, E>
    : I extends Foldable3C<F, E>
    ? PipeableFoldable3C<F, E>
    : {}) &
  (I extends Alt3C<F, E> ? PipeableAlt3C<F, E> : {}) &
  (I extends FilterableWithIndex3C<F, infer Ix, E>
    ? PipeableFilterableWithIndex3C<F, Ix, E>
    : I extends Filterable3C<F, E>
    ? PipeableFilterable3C<F, E>
    : I extends Compactable3C<F, E>
    ? PipeableCompactable3C<F, E>
    : {}) &
  (I extends Profunctor3C<F, E> ? PipeableProfunctor3C<F, E> : {}) &
  (I extends Semigroupoid3C<F, E> ? PipeableSemigroupoid3C<F, E> : {}) &
  (I extends MonadThrow3C<F, E> ? PipeableMonadThrow3C<F, E> : {})
export declare function pipeable<F extends URIS2, I, E>(
  I: { readonly URI: F; readonly _E: E } & I
): (I extends Chain2C<F, E>
  ? PipeableChain2C<F, E>
  : I extends Apply2C<F, E>
  ? PipeableApply2C<F, E>
  : I extends Functor2C<F, E>
  ? PipeableFunctor2C<F, E>
  : {}) &
  (I extends Contravariant2C<F, E> ? PipeableContravariant2C<F, E> : {}) &
  (I extends FunctorWithIndex2C<F, infer Ix, E> ? PipeableFunctorWithIndex2C<F, Ix, E> : {}) &
  (I extends Extend2C<F, E> ? PipeableExtend2C<F, E> : {}) &
  (I extends FoldableWithIndex2C<F, infer Ix, E>
    ? PipeableFoldableWithIndex2C<F, Ix, E>
    : I extends Foldable2C<F, E>
    ? PipeableFoldable2C<F, E>
    : {}) &
  (I extends Alt2C<F, E> ? PipeableAlt2C<F, E> : {}) &
  (I extends FilterableWithIndex2C<F, infer Ix, E>
    ? PipeableFilterableWithIndex2C<F, Ix, E>
    : I extends Filterable2C<F, E>
    ? PipeableFilterable2C<F, E>
    : I extends Compactable2C<F, E>
    ? PipeableCompactable2C<F, E>
    : {}) &
  (I extends Profunctor2C<F, E> ? PipeableProfunctor2C<F, E> : {}) &
  (I extends Semigroupoid2C<F, E> ? PipeableSemigroupoid2C<F, E> : {}) &
  (I extends MonadThrow2C<F, E> ? PipeableMonadThrow2C<F, E> : {})
export declare function pipeable<F extends URIS2, I>(
  I: { readonly URI: F } & I
): (I extends Chain2<F>
  ? PipeableChain2<F>
  : I extends Apply2<F>
  ? PipeableApply2<F>
  : I extends Functor2<F>
  ? PipeableFunctor2<F>
  : {}) &
  (I extends Contravariant2<F> ? PipeableContravariant2<F> : {}) &
  (I extends FunctorWithIndex2<F, infer Ix> ? PipeableFunctorWithIndex2<F, Ix> : {}) &
  (I extends Bifunctor2<F> ? PipeableBifunctor2<F> : {}) &
  (I extends Extend2<F> ? PipeableExtend2<F> : {}) &
  (I extends FoldableWithIndex2<F, infer Ix>
    ? PipeableFoldableWithIndex2<F, Ix>
    : I extends Foldable2<F>
    ? PipeableFoldable2<F>
    : {}) &
  (I extends Alt2<F> ? PipeableAlt2<F> : {}) &
  (I extends FilterableWithIndex2<F, infer Ix>
    ? PipeableFilterableWithIndex2<F, Ix>
    : I extends Filterable2<F>
    ? PipeableFilterable2<F>
    : I extends Compactable2<F>
    ? PipeableCompactable2<F>
    : {}) &
  (I extends Profunctor2<F> ? PipeableProfunctor2<F> : {}) &
  (I extends Semigroupoid2<F> ? PipeableSemigroupoid2<F> : {}) &
  (I extends MonadThrow2<F> ? PipeableMonadThrow2<F> : {})
export declare function pipeable<F extends URIS, I>(
  I: { readonly URI: F } & I
): (I extends Chain1<F>
  ? PipeableChain1<F>
  : I extends Apply1<F>
  ? PipeableApply1<F>
  : I extends Functor1<F>
  ? PipeableFunctor1<F>
  : {}) &
  (I extends Contravariant1<F> ? PipeableContravariant1<F> : {}) &
  (I extends FunctorWithIndex1<F, infer Ix> ? PipeableFunctorWithIndex1<F, Ix> : {}) &
  (I extends Extend1<F> ? PipeableExtend1<F> : {}) &
  (I extends FoldableWithIndex1<F, infer Ix>
    ? PipeableFoldableWithIndex1<F, Ix>
    : I extends Foldable1<F>
    ? PipeableFoldable1<F>
    : {}) &
  (I extends Alt1<F> ? PipeableAlt1<F> : {}) &
  (I extends FilterableWithIndex1<F, infer Ix>
    ? PipeableFilterableWithIndex1<F, Ix>
    : I extends Filterable1<F>
    ? PipeableFilterable1<F>
    : I extends Compactable1<F>
    ? PipeableCompactable1<F>
    : {}) &
  (I extends MonadThrow1<F> ? PipeableMonadThrow1<F> : {})
export declare function pipeable<F, I>(
  I: { readonly URI: F } & I
): (I extends Chain<F>
  ? PipeableChain<F>
  : I extends Apply<F>
  ? PipeableApply<F>
  : I extends Functor<F>
  ? PipeableFunctor<F>
  : {}) &
  (I extends Contravariant<F> ? PipeableContravariant<F> : {}) &
  (I extends FunctorWithIndex<F, infer Ix> ? PipeableFunctorWithIndex<F, Ix> : {}) &
  (I extends Bifunctor<F> ? PipeableBifunctor<F> : {}) &
  (I extends Extend<F> ? PipeableExtend<F> : {}) &
  (I extends FoldableWithIndex<F, infer Ix>
    ? PipeableFoldableWithIndex<F, Ix>
    : I extends Foldable<F>
    ? PipeableFoldable<F>
    : {}) &
  (I extends Alt<F> ? PipeableAlt<F> : {}) &
  (I extends FilterableWithIndex<F, infer Ix>
    ? PipeableFilterableWithIndex<F, Ix>
    : I extends Filterable<F>
    ? PipeableFilterable<F>
    : I extends Compactable<F>
    ? PipeableCompactable<F>
    : {}) &
  (I extends Profunctor<F> ? PipeableProfunctor<F> : {}) &
  (I extends Semigroupoid<F> ? PipeableSemigroupoid<F> : {}) &
  (I extends MonadThrow<F> ? PipeableMonadThrow<F> : {})

Added in v2.0.0 v2.0.0 中添加

Pointed overview  尖锐概述

Added in v2.10.0 v2.10.0 中添加


Table of contents
目录


model   模型

Pointed (interface)   尖头(接口)

Signature 签名

export interface Pointed<F> {
  readonly URI: F
  readonly of: <A>(a: A) => HKT<F, A>
}

Added in v2.10.0 v2.10.0 中添加

Pointed1 (interface)   尖头1(接口)

Signature 签名

export interface Pointed1<F extends URIS> {
  readonly URI: F
  readonly of: <A>(a: A) => Kind<F, A>
}

Added in v2.10.0 v2.10.0 中添加

Pointed2 (interface)   Pointed2(接口)

Signature 签名

export interface Pointed2<F extends URIS2> {
  readonly URI: F
  readonly of: <E, A>(a: A) => Kind2<F, E, A>
}

Added in v2.10.0 v2.10.0 中添加

Pointed2C (interface)   Pointed2C(接口)

Signature 签名

export interface Pointed2C<F extends URIS2, E> {
  readonly URI: F
  readonly _E: E
  readonly of: <A>(a: A) => Kind2<F, E, A>
}

Added in v2.10.0 v2.10.0 中添加

Pointed3 (interface)   Pointed3(接口)

Signature 签名

export interface Pointed3<F extends URIS3> {
  readonly URI: F
  readonly of: <R, E, A>(a: A) => Kind3<F, R, E, A>
}

Added in v2.10.0 v2.10.0 中添加

Pointed3C (interface)   Pointed3C(接口)

Signature 签名

export interface Pointed3C<F extends URIS3, E> {
  readonly URI: F
  readonly _E: E
  readonly of: <R, A>(a: A) => Kind3<F, R, E, A>
}

Added in v2.10.0 v2.10.0 中添加

Pointed4 (interface)   Pointed4(接口)

Signature 签名

export interface Pointed4<F extends URIS4> {
  readonly URI: F
  readonly of: <S, R, E, A>(a: A) => Kind4<F, S, R, E, A>
}

Added in v2.10.0 v2.10.0 中添加

Predicate overview  谓词概述

Added in v2.11.0 v2.11.0 中添加


Table of contents
目录


instances   实例

Contravariant  逆变

Signature 签名

export declare const Contravariant: Contravariant1<'Predicate'>

Added in v2.11.0 v2.11.0 中添加

getMonoidAll   获取MonoidAll

Signature 签名

export declare const getMonoidAll: <A = never>() => Monoid<Predicate<A>>

Added in v2.11.0 v2.11.0 中添加

getMonoidAny   获取MonoidAny

Signature 签名

export declare const getMonoidAny: <A = never>() => Monoid<Predicate<A>>

Added in v2.11.0 v2.11.0 中添加

getSemigroupAll   获取半群全部

Signature 签名

export declare const getSemigroupAll: <A = never>() => Semigroup<Predicate<A>>

Added in v2.11.0 v2.11.0 中添加

getSemigroupAny   获取半群任意

Signature 签名

export declare const getSemigroupAny: <A = never>() => Semigroup<Predicate<A>>

Added in v2.11.0 v2.11.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'Predicate'

Added in v2.11.0 v2.11.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.11.0 v2.11.0 中添加

utils   实用程序

Predicate (interface)   谓词(接口)

Signature 签名

export interface Predicate<A> {
  (a: A): boolean
}

Added in v2.11.0 v2.11.0 中添加

and  

Signature 签名

export declare const and: <A>(second: Predicate<A>) => (first: Predicate<A>) => Predicate<A>

Added in v2.11.0 v2.11.0 中添加

contramap   对比图

Signature 签名

export declare const contramap: <B, A>(f: (b: B) => A) => (predicate: Predicate<A>) => Predicate<B>

Added in v2.11.0 v2.11.0 中添加

not   不是

Signature 签名

export declare const not: <A>(predicate: Predicate<A>) => Predicate<A>

Added in v2.11.0 v2.11.0 中添加

or   或者

Signature 签名

export declare const or: <A>(second: Predicate<A>) => (first: Predicate<A>) => Predicate<A>

Added in v2.11.0 v2.11.0 中添加

Profunctor overview  泛函概述

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Profunctor (interface)   泛函器(接口)

Signature 签名

export interface Profunctor<F> {
  readonly URI: F
  readonly map: <E, A, B>(fa: HKT2<F, E, A>, f: (a: A) => B) => HKT<F, B>
  readonly promap: <E, A, D, B>(fea: HKT2<F, E, A>, f: (d: D) => E, g: (a: A) => B) => HKT2<F, D, B>
}

Added in v2.0.0 v2.0.0 中添加

Profunctor2 (interface)
Profunctor2(接口)

Signature 签名

export interface Profunctor2<F extends URIS2> extends Functor2<F> {
  readonly promap: <E, A, D, B>(fea: Kind2<F, E, A>, f: (d: D) => E, g: (a: A) => B) => Kind2<F, D, B>
}

Added in v2.0.0 v2.0.0 中添加

Profunctor2C (interface)
Profunctor2C(接口)

Signature 签名

export interface Profunctor2C<F extends URIS2, E> extends Functor2C<F, E> {
  readonly promap: <A, D, B>(fea: Kind2<F, E, A>, f: (d: D) => E, g: (a: A) => B) => Kind2<F, D, B>
}

Added in v2.0.0 v2.0.0 中添加

Profunctor3 (interface)
Profunctor3(接口)

Signature 签名

export interface Profunctor3<F extends URIS3> extends Functor3<F> {
  readonly promap: <R, E, A, D, B>(fea: Kind3<F, R, E, A>, f: (d: D) => E, g: (a: A) => B) => Kind3<F, R, D, B>
}

Added in v2.0.0 v2.0.0 中添加

Profunctor3C (interface)
Profunctor3C(接口)

Signature 签名

export interface Profunctor3C<F extends URIS3, E> extends Functor3C<F, E> {
  readonly promap: <R, A, D, B>(fea: Kind3<F, R, E, A>, f: (d: D) => E, g: (a: A) => B) => Kind3<F, R, D, B>
}

Added in v2.2.0 v2.2.0中添加

Profunctor4 (interface)
Profunctor4(接口)

Signature 签名

export interface Profunctor4<F extends URIS4> extends Functor4<F> {
  readonly promap: <S, R, E, A, D, B>(fea: Kind4<F, S, R, E, A>, f: (d: D) => E, g: (a: A) => B) => Kind4<F, S, R, D, B>
}

Added in v2.0.0 v2.0.0 中添加

Random overview  随机概览

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


utils   实用程序

random   随机的

Returns a random number between 0 (inclusive) and 1 (exclusive). This is a direct wrapper around JavaScript’s Math.random().
返回 0(含)和 1(不含)之间的随机数。这是 JavaScript 的 Math.random() 的直接包装。

Signature 签名

export declare const random: IO<number>

Added in v2.0.0 v2.0.0 中添加

randomBool   随机布尔值

Returns a random boolean value with an equal chance of being true or false
返回一个随机布尔值,其成为 truefalse 的机会均等

Signature 签名

export declare const randomBool: IO<boolean>

Added in v2.0.0 v2.0.0 中添加

randomElem   随机元素

Returns a random element of a ReadonlyNonEmptyArray.
返回 ReadonlyNonEmptyArray 的随机元素。

Signature 签名

export declare const randomElem: <A>(as: ReadonlyNonEmptyArray<A>) => IO<A>

Added in v2.10.0 v2.10.0 中添加

randomInt   随机整数

Takes a range specified by low (the first argument) and high (the second), and returns a random integer uniformly distributed in the closed interval [low, high]. It is unspecified what happens if low > high, or if either of low or high is not an integer.
获取由 low (第一个参数)和 high (第二个参数)指定的范围,并返回在闭区间 [low, high] 中均匀分布的随机整数。未指定如果 low > high 、或者 lowhigh 不是整数会发生什么。

Signature 签名

export declare function randomInt(low: number, high: number): IO<number>

Added in v2.0.0 v2.0.0 中添加

randomRange   随机范围

Returns a random number between a minimum value (inclusive) and a maximum value (exclusive). It is unspecified what happens if maximum < minimum.
返回最小值(含)和最大值(不含)之间的随机数。未指定如果 maximum < minimum 会发生什么。

Signature 签名

export declare function randomRange(min: number, max: number): IO<number>

Added in v2.0.0 v2.0.0 中添加

Reader overview  读者概览

The Reader monad (also called the Environment monad). Represents a computation, which can read values from a shared environment, pass values from function to function, and execute sub-computations in a modified environment. Using Reader monad for such computations is often clearer and easier than using the State monad.
Reader monad(也称为环境 monad)。表示一个计算,它可以从共享环境中读取值、在函数之间传递值以及在修改的环境中执行子计算。使用 Reader monad 进行此类计算通常比使用 State monad 更清晰、更容易。

In this example the Reader monad provides access to variable bindings. Bindings are a map of number variables. The variable count contains number of variables in the bindings. You can see how to run a Reader monad and retrieve data from it, how to access the Reader data with ask and asks.
在此示例中, Reader monad 提供对变量绑定的访问。 Bindingsnumber 变量的映射。变量计数包含绑定中变量的数量。您可以看到如何运行 Reader monad 并从中检索数据,如何使用 askasks 访问 Reader 数据。

Example 例子

import { pipe } from 'fp-ts/function'
import * as O from 'fp-ts/Option'
import * as R from 'fp-ts/Reader'
import * as RR from 'fp-ts/ReadonlyRecord'

interface Bindings extends RR.ReadonlyRecord<string, number> {}

// The Reader monad, which implements this complicated check.
const isCountCorrect: R.Reader<Bindings, boolean> = pipe(
  R.Do,
  R.bind('count', () => R.asks(lookupVar('count'))),
  R.bind('bindings', () => R.ask()),
  R.map(({ count, bindings }) => count === RR.size(bindings))
)

// The selector function to use with 'asks'.
// Returns value of the variable with specified name.
const lookupVar =
  (name: string) =>
  (bindings: Bindings): number =>
    pipe(
      bindings,
      RR.lookup(name),
      O.getOrElse(() => 0)
    )

const sampleBindings: Bindings = { count: 3, a: 1, b: 2 }

assert.deepStrictEqual(isCountCorrect(sampleBindings), true)

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


combinators   组合器

tap   轻敲

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tap: {
  <R1, A, R2, _>(self: Reader<R1, A>, f: (a: A) => Reader<R2, _>): Reader<R1 & R2, A>
  <A, R2, _>(f: (a: A) => Reader<R2, _>): <R1>(self: Reader<R1, A>) => Reader<R2 & R1, A>
}

Added in v2.15.0 v2.15.0 中添加

constructors  构造函数

ask  

Reads the current context
读取当前上下文

Signature 签名

export declare const ask: <R>() => Reader<R, R>

Added in v2.0.0 v2.0.0 中添加

asks  

Projects a value from the global context in a Reader
在 Reader 中投影全局上下文中的值

Signature 签名

export declare const asks: <R, A>(f: (r: R) => A) => Reader<R, A>

Added in v2.0.0 v2.0.0 中添加

asksReader   询问读者

Effectfully accesses the environment.
有效地访问环境。

Signature 签名

export declare const asksReader: <R, A>(f: (r: R) => Reader<R, A>) => Reader<R, A>

Added in v2.11.0 v2.11.0 中添加

asksReaderW   询问读者W

Less strict version of asksReader.
asksReader 的不太严格版本。

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const asksReaderW: <R1, R2, A>(f: (r1: R1) => Reader<R2, A>) => Reader<R1 & R2, A>

Added in v2.11.0 v2.11.0 中添加

id   ID

Signature 签名

export declare const id: <A>() => Reader<A, A>

Added in v2.0.0 v2.0.0 中添加

of  

Signature 签名

export declare const of: <R = unknown, A = never>(a: A) => Reader<R, A>

Added in v2.0.0 v2.0.0 中添加

do notation   做记号

Do  

Signature 签名

export declare const Do: Reader<unknown, {}>

Added in v2.9.0 v2.9.0中添加

apS   apS

Signature 签名

export declare const apS: <N, A, E, B>(
  name: Exclude<N, keyof A>,
  fb: Reader<E, B>
) => (fa: Reader<E, A>) => Reader<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

apSW   apSW

Less strict version of apS.
apS 的不太严格版本。

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const apSW: <A, N extends string, R2, B>(
  name: Exclude<N, keyof A>,
  fb: Reader<R2, B>
) => <R1>(fa: Reader<R1, A>) => Reader<R1 & R2, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bind   绑定

Signature 签名

export declare const bind: <N, A, E, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => Reader<E, B>
) => (ma: Reader<E, A>) => Reader<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bindTo   绑定到

Signature 签名

export declare const bindTo: <N>(name: N) => <E, A>(fa: Reader<E, A>) => Reader<E, { readonly [K in N]: A }>

Added in v2.8.0 v2.8.0 中添加

bindW   绑定W

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const bindW: <N extends string, A, R2, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => Reader<R2, B>
) => <R1>(fa: Reader<R1, A>) => Reader<R1 & R2, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

let  

Signature 签名

export declare const let: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => <E>(fa: Reader<E, A>) => Reader<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.13.0 v2.13.0 中添加

instances   实例

Applicative   适用性

Signature 签名

export declare const Applicative: Applicative2<'Reader'>

Added in v2.7.0 v2.7.0 中添加

Apply   申请

Signature 签名

export declare const Apply: Apply2<'Reader'>

Added in v2.10.0 v2.10.0 中添加

Category   类别

Signature 签名

export declare const Category: Category2<'Reader'>

Added in v2.7.0 v2.7.0 中添加

Chain  

Signature 签名

export declare const Chain: chainable.Chain2<'Reader'>

Added in v2.10.0 v2.10.0 中添加

Choice   选择

Signature 签名

export declare const Choice: Choice2<'Reader'>

Added in v2.8.3 v2.8.3 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor2<'Reader'>

Added in v2.7.0 v2.7.0 中添加

Monad   单子

Signature 签名

export declare const Monad: Monad2<'Reader'>

Added in v2.7.0 v2.7.0 中添加

Pointed  

Signature 签名

export declare const Pointed: Pointed2<'Reader'>

Added in v2.10.0 v2.10.0 中添加

Profunctor   教授

Signature 签名

export declare const Profunctor: Profunctor2<'Reader'>

Added in v2.7.0 v2.7.0 中添加

Strong   强的

Signature 签名

export declare const Strong: Strong2<'Reader'>

Added in v2.8.3 v2.8.3 中添加

legacy   遗产

chain  

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chain: <A, R, B>(f: (a: A) => Reader<R, B>) => (ma: Reader<R, A>) => Reader<R, B>

Added in v2.0.0 v2.0.0 中添加

chainFirst   链优先

Alias of tap.  tap 的别名。

Signature 签名

export declare const chainFirst: <A, R, B>(f: (a: A) => Reader<R, B>) => (first: Reader<R, A>) => Reader<R, A>

Added in v2.0.0 v2.0.0 中添加

chainFirstW  链优先W

Alias of tap.  tap 的别名。

Signature 签名

export declare const chainFirstW: <R2, A, B>(
  f: (a: A) => Reader<R2, B>
) => <R1>(ma: Reader<R1, A>) => Reader<R1 & R2, A>

Added in v2.11.0 v2.11.0 中添加

chainW   链W

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chainW: <R2, A, B>(f: (a: A) => Reader<R2, B>) => <R1>(ma: Reader<R1, A>) => Reader<R1 & R2, B>

Added in v2.6.0 v2.6.0 中添加

mapping   映射

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <E, B>(fab: Reader<E, (a: A) => B>) => Reader<E, B>

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => <R>(fa: Reader<R, A>) => Reader<R, B>

Added in v2.0.0 v2.0.0 中添加

model   模型

Reader (interface)   阅读器(界面)

Signature 签名

export interface Reader<R, A> {
  (r: R): A
}

Added in v2.0.0 v2.0.0 中添加

sequencing   测序

flatMap   平面地图

Signature 签名

export declare const flatMap: {
  <A, R2, B>(f: (a: A) => Reader<R2, B>): <R1>(ma: Reader<R1, A>) => Reader<R1 & R2, B>
  <R1, A, R2, B>(ma: Reader<R1, A>, f: (a: A) => Reader<R2, B>): Reader<R1 & R2, B>
}

Added in v2.14.0 v2.14.0 中添加

flatten   压扁

Signature 签名

export declare const flatten: <R, A>(mma: Reader<R, Reader<R, A>>) => Reader<R, A>

Added in v2.0.0 v2.0.0 中添加

flattenW   展平W

Less strict version of flatten.
flatten 的不太严格版本。

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const flattenW: <R1, R2, A>(mma: Reader<R1, Reader<R2, A>>) => Reader<R1 & R2, A>

Added in v2.11.0 v2.11.0 中添加

traversing   穿越

sequenceArray   序列数组

Equivalent to ReadonlyArray#sequence(Applicative). 相当于 ReadonlyArray#sequence(Applicative)

Signature 签名

export declare const sequenceArray: <R, A>(arr: readonly Reader<R, A>[]) => Reader<R, readonly A[]>

Added in v2.9.0 v2.9.0中添加

traverseArray   遍历数组

Equivalent to ReadonlyArray#traverse(Applicative). 相当于 ReadonlyArray#traverse(Applicative)

Signature 签名

export declare const traverseArray: <R, A, B>(
  f: (a: A) => Reader<R, B>
) => (as: readonly A[]) => Reader<R, readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseArrayWithIndex   带索引遍历数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseArrayWithIndex: <R, A, B>(
  f: (index: number, a: A) => Reader<R, B>
) => (as: readonly A[]) => Reader<R, readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseReadonlyArrayWithIndex
遍历带索引的只读数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseReadonlyArrayWithIndex: <A, R, B>(
  f: (index: number, a: A) => Reader<R, B>
) => (as: readonly A[]) => Reader<R, readonly B[]>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyNonEmptyArrayWithIndex
遍历ReadonlyNonEmptyArrayWithIndex

Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(Applicative). 相当于 ReadonlyNonEmptyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseReadonlyNonEmptyArrayWithIndex: <A, R, B>(
  f: (index: number, a: A) => Reader<R, B>
) => (as: ReadonlyNonEmptyArray<A>) => Reader<R, ReadonlyNonEmptyArray<B>>

Added in v2.11.0 v2.11.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'Reader'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

ApT   易于

Signature 签名

export declare const ApT: Reader<unknown, readonly []>

Added in v2.11.0 v2.11.0 中添加

ap   美联社

Signature 签名

export declare const ap: <R, A>(fa: Reader<R, A>) => <B>(fab: Reader<R, (a: A) => B>) => Reader<R, B>

Added in v2.0.0 v2.0.0 中添加

apFirst   应用程序第一

Combine two effectful actions, keeping only the result of the first.
结合两个有效的操作,仅保留第一个操作的结果。

Signature 签名

export declare const apFirst: <E, B>(second: Reader<E, B>) => <A>(first: Reader<E, A>) => Reader<E, A>

Added in v2.0.0 v2.0.0 中添加

apFirstW   apFirstW

Less strict version of apFirst.
apFirst 的不太严格版本。

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const apFirstW: <R2, B>(second: Reader<R2, B>) => <R1, A>(first: Reader<R1, A>) => Reader<R1 & R2, A>

Added in v2.12.0 v2.12.0 中添加

apSecond   ap秒

Combine two effectful actions, keeping only the result of the second.
结合两个有效的操作,只保留第二个的结果。

Signature 签名

export declare const apSecond: <E, B>(second: Reader<E, B>) => <A>(first: Reader<E, A>) => Reader<E, B>

Added in v2.0.0 v2.0.0 中添加

apSecondW   apSecondW

Less strict version of apSecond.
apSecond 的不太严格版本。

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const apSecondW: <R2, B>(second: Reader<R2, B>) => <R1, A>(first: Reader<R1, A>) => Reader<R1 & R2, B>

Added in v2.12.0 v2.12.0 中添加

apW   平均功率

Less strict version of ap.
ap 的不太严格版本。

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const apW: <R2, A>(fa: Reader<R2, A>) => <R1, B>(fab: Reader<R1, (a: A) => B>) => Reader<R1 & R2, B>

Added in v2.8.0 v2.8.0 中添加

compose   撰写

Signature 签名

export declare const compose: <A, B>(ab: Reader<A, B>) => <C>(bc: Reader<B, C>) => Reader<A, C>

Added in v2.0.0 v2.0.0 中添加

first   第一的

Signature 签名

export declare const first: <A, B, C>(pab: Reader<A, B>) => Reader<[A, C], [B, C]>

Added in v2.10.0 v2.10.0 中添加

left  左边

Signature 签名

export declare const left: <A, B, C>(pab: Reader<A, B>) => Reader<E.Either<A, C>, E.Either<B, C>>

Added in v2.10.0 v2.10.0 中添加

local   当地的

Changes the value of the local context during the execution of the action ma (similar to Contravariant’s contramap).
在执行操作 ma 期间更改本地上下文的值(类似于 Contravariantcontramap )。

Signature 签名

export declare const local: <R2, R1>(f: (r2: R2) => R1) => <A>(ma: Reader<R1, A>) => Reader<R2, A>

Example 例子

import { pipe } from 'fp-ts/function'
import * as R from 'fp-ts/Reader'
import * as string from 'fp-ts/string'

const calculateContentLen: R.Reader<string, number> = pipe(
  R.Do,
  R.bind('content', () => R.ask<string>()),
  R.map(({ content }) => string.size(content))
)

// Calls calculateContentLen after adding a prefix to the Reader content.
const calculateModifiedContentLen: R.Reader<string, number> = pipe(
  calculateContentLen,
  R.local((s) => 'Prefix ' + s)
)

const s = '12345'

assert.deepStrictEqual(
  "Modified 's' length: " + calculateModifiedContentLen(s) + '\n' + "Original 's' length: " + calculateContentLen(s),
  "Modified 's' length: 12\nOriginal 's' length: 5"
)

Added in v2.0.0 v2.0.0 中添加

promap   普罗普

Signature 签名

export declare const promap: <E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fea: Reader<E, A>) => Reader<D, B>

Added in v2.0.0 v2.0.0 中添加

Signature 签名

export declare const right: <A, B, C>(pbc: Reader<B, C>) => Reader<E.Either<A, B>, E.Either<A, C>>

Added in v2.10.0 v2.10.0 中添加

second   第二

Signature 签名

export declare const second: <A, B, C>(pab: Reader<B, C>) => Reader<[A, B], [A, C]>

Added in v2.10.0 v2.10.0 中添加

zone of death
死亡地带

getMonoid 获取Monoid

Use getApplicativeMonoid instead. 请改用 getApplicativeMonoid

Signature 签名

export declare const getMonoid: <R, A>(M: Monoid<A>) => Monoid<Reader<R, A>>

Added in v2.0.0 v2.0.0 中添加

getSemigroup 获取半群

Use getApplySemigroup instead. 请改用 getApplySemigroup

Signature 签名

export declare const getSemigroup: <R, A>(S: Semigroup<A>) => Semigroup<Reader<R, A>>

Added in v2.0.0 v2.0.0 中添加

reader 读者

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass R.Functor instead of R.reader (where R is from import R from 'fp-ts/Reader')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 R.Functor 而不是 R.reader (其中 R 来自 import R from 'fp-ts/Reader'

Signature 签名

export declare const reader: Monad2<'Reader'> &
  Profunctor2<'Reader'> &
  Category2<'Reader'> &
  Strong2<'Reader'> &
  Choice2<'Reader'>

Added in v2.0.0 v2.0.0 中添加

ReaderEither overview  读者要么概述

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


combinators   组合器

tap   轻敲

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tap: {
  <R1, E1, A, R2, E2, _>(self: ReaderEither<R1, E1, A>, f: (a: A) => ReaderEither<R2, E2, _>): ReaderEither<
    R1 & R2,
    E1 | E2,
    A
  >
  <A, R2, E2, _>(f: (a: A) => ReaderEither<R2, E2, _>): <R1, E1>(
    self: ReaderEither<R1, E1, A>
  ) => ReaderEither<R1 & R2, E2 | E1, A>
}

Added in v2.15.0 v2.15.0 中添加

tapEither   点击任一

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapEither: {
  <A, E2, _>(f: (a: A) => E.Either<E2, _>): <R1, E1>(self: ReaderEither<R1, E1, A>) => ReaderEither<R1, E2 | E1, A>
  <R1, E1, A, E2, _>(self: ReaderEither<R1, E1, A>, f: (a: A) => E.Either<E2, _>): ReaderEither<R1, E1 | E2, A>
}

Example 例子

import * as E from 'fp-ts/Either'
import { pipe } from 'fp-ts/function'
import * as RE from 'fp-ts/ReaderEither'

const checkString = (value: string) =>
  pipe(
    RE.ask<number>(),
    RE.tapEither((minLength) => (value.length > minLength ? E.right('ok') : E.left('error')))
  )

assert.deepStrictEqual(checkString('')(1), E.left('error'))
assert.deepStrictEqual(checkString('fp-ts')(2), E.right(2))

Added in v2.16.0 v2.16.0 中添加

tapReader   点击阅读器

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapReader: {
  <R2, A, E, _>(f: (a: A) => R.Reader<R2, _>): <R1>(self: ReaderEither<R1, E, A>) => ReaderEither<R1 & R2, E, A>
  <R1, R2, E, A, _>(self: ReaderEither<R1, E, A>, f: (a: A) => R.Reader<R2, _>): ReaderEither<R1 & R2, E, A>
}

Added in v2.16.0 v2.16.0 中添加

constructors  构造函数

ask  

Reads the current context.
读取当前上下文。

Signature 签名

export declare const ask: <R, E = never>() => ReaderEither<R, E, R>

Added in v2.0.0 v2.0.0 中添加

asks  

Projects a value from the global context in a ReaderEither.
将全局上下文中的值投影到 ReaderEither 中。

Signature 签名

export declare const asks: <R, A, E = never>(f: (r: R) => A) => ReaderEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

asksReaderEither   询问读者要么

Effectfully accesses the environment.
有效地访问环境。

Signature 签名

export declare const asksReaderEither: <R, E, A>(f: (r: R) => ReaderEither<R, E, A>) => ReaderEither<R, E, A>

Added in v2.11.0 v2.11.0 中添加

asksReaderEitherW   询问读者要么W

Less strict version of asksReaderEither.
asksReaderEither 的不太严格版本。

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const asksReaderEitherW: <R1, R2, E, A>(
  f: (r1: R1) => ReaderEither<R2, E, A>
) => ReaderEither<R1 & R2, E, A>

Added in v2.11.0 v2.11.0 中添加

left  左边

Signature 签名

export declare const left: <R, E = never, A = never>(e: E) => ReaderEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

leftReader   左读者

Signature 签名

export declare const leftReader: <R, E = never, A = never>(me: R.Reader<R, E>) => ReaderEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

of  

Signature 签名

export declare const of: <R = unknown, E = never, A = never>(a: A) => ReaderEither<R, E, A>

Added in v2.8.5 v2.8.5 中添加

Signature 签名

export declare const right: <R, E = never, A = never>(a: A) => ReaderEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

rightReader   右阅读器

Signature 签名

export declare const rightReader: <R, E = never, A = never>(ma: R.Reader<R, A>) => ReaderEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

conversions   转换

fromEither   来自任一

Signature 签名

export declare const fromEither: <E, A, R = unknown>(fa: E.Either<E, A>) => ReaderEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

fromOption   来自选项

Signature 签名

export declare const fromOption: <E>(onNone: LazyArg<E>) => <A, R = unknown>(fa: Option<A>) => ReaderEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

fromReader   来自读者

Signature 签名

export declare const fromReader: <R, A, E = never>(fa: R.Reader<R, A>) => ReaderEither<R, E, A>

Added in v2.11.0 v2.11.0 中添加

toUnion   至联盟

Signature 签名

export declare const toUnion: <R, E, A>(fa: ReaderEither<R, E, A>) => R.Reader<R, E | A>

Added in v2.10.0 v2.10.0 中添加

do notation   做记号

Do  

Signature 签名

export declare const Do: ReaderEither<unknown, never, {}>

Added in v2.9.0 v2.9.0中添加

apS   apS

Signature 签名

export declare const apS: <N, A, R, E, B>(
  name: Exclude<N, keyof A>,
  fb: ReaderEither<R, E, B>
) => (fa: ReaderEither<R, E, A>) => ReaderEither<R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

apSW   apSW

Less strict version of apS.
apS 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const apSW: <A, N extends string, R2, E2, B>(
  name: Exclude<N, keyof A>,
  fb: ReaderEither<R2, E2, B>
) => <R1, E1>(
  fa: ReaderEither<R1, E1, A>
) => ReaderEither<R1 & R2, E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bind   绑定

Signature 签名

export declare const bind: <N, A, R, E, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => ReaderEither<R, E, B>
) => (ma: ReaderEither<R, E, A>) => ReaderEither<R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bindTo   绑定到

Signature 签名

export declare const bindTo: <N>(
  name: N
) => <R, E, A>(fa: ReaderEither<R, E, A>) => ReaderEither<R, E, { readonly [K in N]: A }>

Added in v2.8.0 v2.8.0 中添加

bindW   绑定W

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const bindW: <N extends string, A, R2, E2, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => ReaderEither<R2, E2, B>
) => <R1, E1>(
  fa: ReaderEither<R1, E1, A>
) => ReaderEither<R1 & R2, E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

let  

Signature 签名

export declare const let: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => <R, E>(
  fa: ReaderEither<R, E, A>
) => ReaderEither<R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.13.0 v2.13.0 中添加

error handling   错误处理

alt   替代

Identifies an associative operation on a type constructor. It is similar to Semigroup, except that it applies to types of kind * -> *.
标识类型构造函数上的关联操作。它与 Semigroup 类似,但它适用于 * -> * 类型。

Signature 签名

export declare const alt: <R, E, A>(
  that: () => ReaderEither<R, E, A>
) => (fa: ReaderEither<R, E, A>) => ReaderEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

altW   替代W

Less strict version of alt.
alt 的不太严格版本。

The W suffix (short for Widening) means that the environment, the error and the return types will be merged.
W 后缀(Widening 的缩写)意味着环境、错误和返回类型将被合并。

Signature 签名

export declare const altW: <R2, E2, B>(
  that: () => ReaderEither<R2, E2, B>
) => <R1, E1, A>(fa: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E2, B | A>

Added in v2.9.0 v2.9.0中添加

getAltReaderValidation   获取AltReaderValidation

The default Alt instance returns the last error, if you want to get all errors you need to provide a way to concatenate them via a Semigroup.
默认的 Alt 实例返回最后一个错误,如果你想获取所有错误,你需要提供一种通过 Semigroup 连接它们的方法。

See getAltValidation. 请参阅 getAltValidation

Signature 签名

export declare function getAltReaderValidation<E>(S: Semigroup<E>): Alt3C<URI, E>

Added in v2.7.0 v2.7.0 中添加

getApplicativeReaderValidation
获取ApplicativeReaderValidation

The default Applicative instance returns the first error, if you want to get all errors you need to provide a way to concatenate them via a Semigroup.
默认的 Applicative 实例返回第一个错误,如果您想获取所有错误,您需要提供一种通过 Semigroup 连接它们的方法。

See getApplicativeValidation. 请参阅 getApplicativeValidation

Signature 签名

export declare function getApplicativeReaderValidation<E>(S: Semigroup<E>): Applicative3C<URI, E>

Added in v2.7.0 v2.7.0 中添加

getOrElse  获取或否则

Signature 签名

export declare const getOrElse: <E, R, A>(
  onLeft: (e: E) => R.Reader<R, A>
) => (ma: ReaderEither<R, E, A>) => R.Reader<R, A>

Added in v2.0.0 v2.0.0 中添加

getOrElseW   获取或否则W

Less strict version of getOrElse.
getOrElse 的不太严格版本。

The W suffix (short for Widening) means that the handler return type will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const getOrElseW: <R2, E, B>(
  onLeft: (e: E) => R.Reader<R2, B>
) => <R1, A>(ma: ReaderEither<R1, E, A>) => R.Reader<R1 & R2, B | A>

Added in v2.6.0 v2.6.0 中添加

mapBoth   地图两者

Returns a ReaderEither whose failure and success channels have been mapped by the specified pair of functions, f and g.
返回一个 ReaderEither ,其失败和成功通道已由指定的函数对 fg 映射。

Signature 签名

export declare const mapBoth: {
  <E, G, A, B>(f: (e: E) => G, g: (a: A) => B): <R>(self: ReaderEither<R, E, A>) => ReaderEither<R, G, B>
  <R, E, A, G, B>(self: ReaderEither<R, E, A>, f: (e: E) => G, g: (a: A) => B): ReaderEither<R, G, B>
}

Example 例子

import * as ReaderEither from 'fp-ts/ReaderEither'
import * as Either from 'fp-ts/Either'

const f = (s: string) => new Error(s)
const g = (n: number) => n * 2

assert.deepStrictEqual(ReaderEither.mapBoth(ReaderEither.right(1), f, g)({}), Either.right(2))
assert.deepStrictEqual(ReaderEither.mapBoth(ReaderEither.left('err'), f, g)({}), Either.left(new Error('err')))

Added in v2.16.0 v2.16.0 中添加

mapError   地图错误

Returns a ReaderEither with its error channel mapped using the specified function.
返回 ReaderEither 及其使用指定函数映射的错误通道。

Signature 签名

export declare const mapError: {
  <R, E, G>(f: (e: E) => G): <A>(self: ReaderEither<R, E, A>) => ReaderEither<R, G, A>
  <R, E, A, G>(self: ReaderEither<R, E, A>, f: (e: E) => G): ReaderEither<R, G, A>
}

Example 例子

import * as ReaderEither from 'fp-ts/ReaderEither'
import * as Either from 'fp-ts/Either'

const f = (s: string) => new Error(s)

assert.deepStrictEqual(ReaderEither.mapError(ReaderEither.right(1), f)({}), Either.right(1))
assert.deepStrictEqual(ReaderEither.mapError(ReaderEither.left('err'), f)({}), Either.left(new Error('err')))

Added in v2.16.0 v2.16.0 中添加

orElse   要不然

Signature 签名

export declare const orElse: <E1, R, E2, A>(
  onLeft: (e: E1) => ReaderEither<R, E2, A>
) => (ma: ReaderEither<R, E1, A>) => ReaderEither<R, E2, A>

Added in v2.0.0 v2.0.0 中添加

orElseW   否则W

Less strict version of orElse.
orElse 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the return types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和返回类型将被合并。

Signature 签名

export declare const orElseW: <E1, R1, E2, B>(
  onLeft: (e: E1) => ReaderEither<R1, E2, B>
) => <R2, A>(ma: ReaderEither<R2, E1, A>) => ReaderEither<R1 & R2, E2, B | A>

Added in v2.10.0 v2.10.0 中添加

orLeft   或向左

Signature 签名

export declare const orLeft: <E1, R, E2>(
  onLeft: (e: E1) => R.Reader<R, E2>
) => <A>(fa: ReaderEither<R, E1, A>) => ReaderEither<R, E2, A>

Added in v2.11.0 v2.11.0 中添加

tapError   点击错误

Returns an effect that effectfully “peeks” at the failure of this effect.
返回一个效果,有效地“窥视”此效果的失败。

Signature 签名

export declare const tapError: {
  <E1, R2, E2, _>(onLeft: (e: E1) => ReaderEither<R2, E2, _>): <R1, A>(
    self: ReaderEither<R1, E1, A>
  ) => ReaderEither<R1 & R2, E1 | E2, A>
  <R1, E1, A, R2, E2, _>(self: ReaderEither<R1, E1, A>, onLeft: (e: E1) => ReaderEither<R2, E2, _>): ReaderEither<
    R1 & R2,
    E1 | E2,
    A
  >
}

Added in v2.15.0 v2.15.0 中添加

filtering   过滤

filterOrElse  过滤器或者其他

Signature 签名

export declare const filterOrElse: {
  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(
    ma: ReaderEither<R, E, A>
  ) => ReaderEither<R, E, B>
  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R, B extends A>(
    mb: ReaderEither<R, E, B>
  ) => ReaderEither<R, E, B>
  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, A>
}

Added in v2.0.0 v2.0.0 中添加

filterOrElseW   过滤器否则W

Less strict version of filterOrElse.
filterOrElse 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const filterOrElseW: {
  <A, B extends A, E2>(refinement: Refinement<A, B>, onFalse: (a: A) => E2): <R, E1>(
    ma: ReaderEither<R, E1, A>
  ) => ReaderEither<R, E2 | E1, B>
  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <R, E1, B extends A>(
    mb: ReaderEither<R, E1, B>
  ) => ReaderEither<R, E2 | E1, B>
  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <R, E1>(
    ma: ReaderEither<R, E1, A>
  ) => ReaderEither<R, E2 | E1, A>
}

Added in v2.9.0 v2.9.0中添加

getCompactable   获取可压缩的

Signature 签名

export declare const getCompactable: <E>(M: Monoid<E>) => Compactable3C<'ReaderEither', E>

Added in v2.10.0 v2.10.0 中添加

getFilterable   获取可过滤的

Signature 签名

export declare function getFilterable<E>(M: Monoid<E>): Filterable3C<URI, E>

Added in v2.10.0 v2.10.0 中添加

instances   实例

Alt   替代

Signature 签名

export declare const Alt: Alt3<'ReaderEither'>

Added in v2.7.0 v2.7.0 中添加

Applicative   适用性

Signature 签名

export declare const Applicative: Applicative3<'ReaderEither'>

Added in v2.7.0 v2.7.0 中添加

Apply   申请

Signature 签名

export declare const Apply: Apply3<'ReaderEither'>

Added in v2.10.0 v2.10.0 中添加

Bifunctor   双函子

Signature 签名

export declare const Bifunctor: Bifunctor3<'ReaderEither'>

Added in v2.7.0 v2.7.0 中添加

Chain  

Signature 签名

export declare const Chain: chainable.Chain3<'ReaderEither'>

Added in v2.10.0 v2.10.0 中添加

FromEither   来自任一

Signature 签名

export declare const FromEither: FromEither3<'ReaderEither'>

Added in v2.10.0 v2.10.0 中添加

FromReader   来自读者

Signature 签名

export declare const FromReader: FromReader3<'ReaderEither'>

Added in v2.11.0 v2.11.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor3<'ReaderEither'>

Added in v2.7.0 v2.7.0 中添加

Monad   单子

Signature 签名

export declare const Monad: Monad3<'ReaderEither'>

Added in v2.7.0 v2.7.0 中添加

MonadThrow   单子投掷

Signature 签名

export declare const MonadThrow: MonadThrow3<'ReaderEither'>

Added in v2.7.0 v2.7.0 中添加

Pointed  

Signature 签名

export declare const Pointed: Pointed3<'ReaderEither'>

Added in v2.10.0 v2.10.0 中添加

legacy   遗产

bimap   双图

Alias of mapBoth.  mapBoth 的别名。

Signature 签名

export declare const bimap: <E, G, A, B>(
  f: (e: E) => G,
  g: (a: A) => B
) => <R>(fa: ReaderEither<R, E, A>) => ReaderEither<R, G, B>

Added in v2.0.0 v2.0.0 中添加

chain  

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chain: <R, E, A, B>(
  f: (a: A) => ReaderEither<R, E, B>
) => (ma: ReaderEither<R, E, A>) => ReaderEither<R, E, B>

Added in v2.0.0 v2.0.0 中添加

chainEitherK  链EiK

Alias of flatMapEither.  flatMapEither 的别名。

Signature 签名

export declare const chainEitherK: <E, A, B>(
  f: (a: A) => E.Either<E, B>
) => <R>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, B>

Added in v2.4.0 v2.4.0中添加

chainEitherKW  链条任一KW

Alias of flatMapEither.  flatMapEither 的别名。

Signature 签名

export declare const chainEitherKW: <E2, A, B>(
  f: (a: A) => E.Either<E2, B>
) => <R, E1>(ma: ReaderEither<R, E1, A>) => ReaderEither<R, E2 | E1, B>

Added in v2.6.1 v2.6.1 中添加

chainFirst   链优先

Alias of tap.  tap 的别名。

Signature 签名

export declare const chainFirst: <R, E, A, B>(
  f: (a: A) => ReaderEither<R, E, B>
) => (ma: ReaderEither<R, E, A>) => ReaderEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

chainFirstEitherK  链FirstEiK

Alias of tapEither.  tapEither 的别名。

Signature 签名

export declare const chainFirstEitherK: <A, E, B>(
  f: (a: A) => E.Either<E, B>
) => <R>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, A>

Added in v2.12.0 v2.12.0 中添加

chainFirstEitherKW   链FirstEiKW

Alias of tapEither.  tapEither 的别名。

Less strict version of chainFirstEitherK.
chainFirstEitherK 的不太严格版本。

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const chainFirstEitherKW: <A, E2, B>(
  f: (a: A) => E.Either<E2, B>
) => <R, E1>(ma: ReaderEither<R, E1, A>) => ReaderEither<R, E2 | E1, A>

Added in v2.12.0 v2.12.0 中添加

chainFirstReaderK  链第一读者K

Alias of tapReader.  tapReader 的别名。

Signature 签名

export declare const chainFirstReaderK: <A, R, B>(
  f: (a: A) => R.Reader<R, B>
) => <E>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, A>

Added in v2.11.0 v2.11.0 中添加

chainFirstReaderKW  chainFirstReaderKW

Alias of tapReader.  tapReader 的别名。

Less strict version of chainReaderK.
chainReaderK 的不太严格版本。

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const chainFirstReaderKW: <A, R1, B>(
  f: (a: A) => R.Reader<R1, B>
) => <R2, E>(ma: ReaderEither<R2, E, A>) => ReaderEither<R1 & R2, E, A>

Added in v2.11.0 v2.11.0 中添加

chainFirstW  链优先W

Alias of tap.  tap 的别名。

Signature 签名

export declare const chainFirstW: <R2, E2, A, B>(
  f: (a: A) => ReaderEither<R2, E2, B>
) => <R1, E1>(ma: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E2 | E1, A>

Added in v2.8.0 v2.8.0 中添加

chainOptionK   链选项K

Use flatMapOption. 使用 flatMapOption

Signature 签名

export declare const chainOptionK: <E>(
  onNone: LazyArg<E>
) => <A, B>(f: (a: A) => Option<B>) => <R>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, B>

Added in v2.10.0 v2.10.0 中添加

chainOptionKW   链条选项KW

Use flatMapOption. 使用 flatMapOption

Signature 签名

export declare const chainOptionKW: <E2>(
  onNone: LazyArg<E2>
) => <A, B>(f: (a: A) => Option<B>) => <R, E1>(ma: ReaderEither<R, E1, A>) => ReaderEither<R, E2 | E1, B>

Added in v2.13.2 v2.13.2 中添加

chainReaderK  链读器K

Alias of flatMapReader.  flatMapReader 的别名。

Signature 签名

export declare const chainReaderK: <A, R, B>(
  f: (a: A) => R.Reader<R, B>
) => <E>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, B>

Added in v2.11.0 v2.11.0 中添加

chainReaderKW  链式阅读器KW

Alias of flatMapReader.  flatMapReader 的别名。

Less strict version of chainReaderK.
chainReaderK 的不太严格版本。

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const chainReaderKW: <A, R2, B>(
  f: (a: A) => R.Reader<R2, B>
) => <R1, E>(ma: ReaderEither<R1, E, A>) => ReaderEither<R1 & R2, E, B>

Added in v2.11.0 v2.11.0 中添加

chainW   链W

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chainW: <R2, E2, A, B>(
  f: (a: A) => ReaderEither<R2, E2, B>
) => <R1, E1>(ma: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E2 | E1, B>

Added in v2.6.0 v2.6.0 中添加

fromOptionK   来自选项K

Use liftOption. 使用 liftOption

Signature 签名

export declare const fromOptionK: <E>(
  onNone: LazyArg<E>
) => <A extends readonly unknown[], B>(f: (...a: A) => Option<B>) => <R = unknown>(...a: A) => ReaderEither<R, E, B>

Added in v2.10.0 v2.10.0 中添加

mapLeft   地图左

Alias of mapError.  mapError 的别名。

Signature 签名

export declare const mapLeft: <E, G>(f: (e: E) => G) => <R, A>(fa: ReaderEither<R, E, A>) => ReaderEither<R, G, A>

Added in v2.0.0 v2.0.0 中添加

orElseFirst   或其他优先

Alias of tapError.  tapError 的别名。

Signature 签名

export declare const orElseFirst: <E, R, B>(
  onLeft: (e: E) => ReaderEither<R, E, B>
) => <A>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, A>

Added in v2.11.0 v2.11.0 中添加

orElseFirstW   否则先W

Alias of tapError.  tapError 的别名。

Signature 签名

export declare const orElseFirstW: <E1, R2, E2, B>(
  onLeft: (e: E1) => ReaderEither<R2, E2, B>
) => <R1, A>(ma: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E1 | E2, A>

Added in v2.11.0 v2.11.0 中添加

lifting   起重

fromEitherK   来自EitherK

Signature 签名

export declare const fromEitherK: <E, A extends readonly unknown[], B>(
  f: (...a: A) => E.Either<E, B>
) => <R = unknown>(...a: A) => ReaderEither<R, E, B>

Added in v2.4.0 v2.4.0中添加

fromPredicate   来自谓词

Signature 签名

export declare const fromPredicate: {
  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R = unknown>(a: A) => ReaderEither<R, E, B>
  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R = unknown, B extends A = A>(b: B) => ReaderEither<R, E, B>
  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R = unknown>(a: A) => ReaderEither<R, E, A>
}

Added in v2.0.0 v2.0.0 中添加

fromReaderK   来自ReaderK

Signature 签名

export declare const fromReaderK: <A extends readonly unknown[], R, B>(
  f: (...a: A) => R.Reader<R, B>
) => <E = never>(...a: A) => ReaderEither<R, E, B>

Added in v2.11.0 v2.11.0 中添加

liftNullable   提升可为空

Signature 签名

export declare const liftNullable: <A extends readonly unknown[], B, E>(
  f: (...a: A) => B | null | undefined,
  onNullable: (...a: A) => E
) => <R>(...a: A) => ReaderEither<R, E, NonNullable<B>>

Added in v2.15.0 v2.15.0 中添加

liftOption   电梯选项

Signature 签名

export declare const liftOption: <A extends readonly unknown[], B, E>(
  f: (...a: A) => Option<B>,
  onNone: (...a: A) => E
) => <R>(...a: A) => ReaderEither<R, E, B>

Added in v2.15.0 v2.15.0 中添加

mapping   映射

as   作为

Maps the Right value of this ReaderEither to the specified constant value.
将此 ReaderEitherRight 值映射到指定的常量值。

Signature 签名

export declare const as: {
  <A>(a: A): <R, E, _>(self: ReaderEither<R, E, _>) => ReaderEither<R, E, A>
  <R, E, _, A>(self: ReaderEither<R, E, _>, a: A): ReaderEither<R, E, A>
}

Added in v2.16.0 v2.16.0 中添加

asUnit   作为单位

Maps the Right value of this ReaderEither to the void constant value.
将此 ReaderEitherRight 值映射到void 常量值。

Signature 签名

export declare const asUnit: <R, E, _>(self: ReaderEither<R, E, _>) => ReaderEither<R, E, void>

Added in v2.16.0 v2.16.0 中添加

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <R, E, B>(fab: ReaderEither<R, E, (a: A) => B>) => ReaderEither<R, E, B>

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => <R, E>(fa: ReaderEither<R, E, A>) => ReaderEither<R, E, B>

Added in v2.0.0 v2.0.0 中添加

model   模型

ReaderEither (interface)
ReaderEither(接口)

Signature 签名

export interface ReaderEither<R, E, A> extends Reader<R, Either<E, A>> {}

Added in v2.0.0 v2.0.0 中添加

pattern matching   模式匹配

fold   折叠

Alias of matchE.  matchE 的别名。

Signature 签名

export declare const fold: <R, E, A, B>(
  onLeft: (e: E) => R.Reader<R, B>,
  onRight: (a: A) => R.Reader<R, B>
) => (ma: ReaderEither<R, E, A>) => R.Reader<R, B>

Added in v2.0.0 v2.0.0 中添加

foldW   折叠W

Alias of matchEW.  matchEW 的别名。

Signature 签名

export declare const foldW: <E, R2, B, A, R3, C>(
  onLeft: (e: E) => R.Reader<R2, B>,
  onRight: (a: A) => R.Reader<R3, C>
) => <R1>(ma: ReaderEither<R1, E, A>) => R.Reader<R1 & R2 & R3, B | C>

Added in v2.10.0 v2.10.0 中添加

match   匹配

Signature 签名

export declare const match: <E, B, A>(
  onLeft: (e: E) => B,
  onRight: (a: A) => B
) => <R>(ma: ReaderEither<R, E, A>) => R.Reader<R, B>

Added in v2.10.0 v2.10.0 中添加

matchE   匹配E

The E suffix (short for Effect) means that the handlers return an effect (Reader).
E 后缀(Effect 的缩写)意味着处理程序返回一个效果 ( Reader )。

Signature 签名

export declare const matchE: <R, E, A, B>(
  onLeft: (e: E) => R.Reader<R, B>,
  onRight: (a: A) => R.Reader<R, B>
) => (ma: ReaderEither<R, E, A>) => R.Reader<R, B>

Added in v2.10.0 v2.10.0 中添加

matchEW   匹配电子战

Less strict version of matchE.
matchE 的不太严格版本。

The W suffix (short for Widening) means that the handler return types will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const matchEW: <E, R2, B, A, R3, C>(
  onLeft: (e: E) => R.Reader<R2, B>,
  onRight: (a: A) => R.Reader<R3, C>
) => <R1>(ma: ReaderEither<R1, E, A>) => R.Reader<R1 & R2 & R3, B | C>

Added in v2.10.0 v2.10.0 中添加

matchW   匹配W

Less strict version of match.
match 的不太严格版本。

The W suffix (short for Widening) means that the handler return types will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const matchW: <E, B, A, C>(
  onLeft: (e: E) => B,
  onRight: (a: A) => C
) => <R>(ma: R.Reader<R, E.Either<E, A>>) => R.Reader<R, B | C>

Added in v2.10.0 v2.10.0 中添加

sequencing   测序

flatMap   平面地图

Signature 签名

export declare const flatMap: {
  <A, R2, E2, B>(f: (a: A) => ReaderEither<R2, E2, B>): <R1, E1>(
    ma: ReaderEither<R1, E1, A>
  ) => ReaderEither<R1 & R2, E2 | E1, B>
  <R1, E1, A, R2, E2, B>(ma: ReaderEither<R1, E1, A>, f: (a: A) => ReaderEither<R2, E2, B>): ReaderEither<
    R1 & R2,
    E1 | E2,
    B
  >
}

Added in v2.14.0 v2.14.0 中添加

flatMapEither   平面地图要么

Signature 签名

export declare const flatMapEither: {
  <A, E2, B>(f: (a: A) => E.Either<E2, B>): <R, E1>(self: ReaderEither<R, E1, A>) => ReaderEither<R, E2 | E1, B>
  <R, E1, A, E2, B>(self: ReaderEither<R, E1, A>, f: (a: A) => E.Either<E2, B>): ReaderEither<R, E1 | E2, B>
}

Added in v2.15.0 v2.15.0 中添加

flatMapNullable   平面地图可空

Signature 签名

export declare const flatMapNullable: {
  <A, B, E2>(f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): <R, E1>(
    self: ReaderEither<R, E1, A>
  ) => ReaderEither<R, E2 | E1, NonNullable<B>>
  <R, E1, A, B, E2>(
    self: ReaderEither<R, E1, A>,
    f: (a: A) => B | null | undefined,
    onNullable: (a: A) => E2
  ): ReaderEither<R, E1 | E2, NonNullable<B>>
}

Added in v2.15.0 v2.15.0 中添加

flatMapOption   平面地图选项

Signature 签名

export declare const flatMapOption: {
  <A, B, E2>(f: (a: A) => Option<B>, onNone: (a: A) => E2): <R, E1>(
    self: ReaderEither<R, E1, A>
  ) => ReaderEither<R, E2 | E1, B>
  <R, E1, A, B, E2>(self: ReaderEither<R, E1, A>, f: (a: A) => Option<B>, onNone: (a: A) => E2): ReaderEither<
    R,
    E1 | E2,
    B
  >
}

Added in v2.15.0 v2.15.0 中添加

flatMapReader   平面地图阅读器

Signature 签名

export declare const flatMapReader: {
  <A, R2, B>(f: (a: A) => R.Reader<R2, B>): <R1, E>(self: ReaderEither<R1, E, A>) => ReaderEither<R1 & R2, E, B>
  <R1, E, A, R2, B>(self: ReaderEither<R1, E, A>, f: (a: A) => R.Reader<R2, B>): ReaderEither<R1 & R2, E, B>
}

Added in v2.16.0 v2.16.0 中添加

flatten   压扁

Signature 签名

export declare const flatten: <R, E, A>(mma: ReaderEither<R, E, ReaderEither<R, E, A>>) => ReaderEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

flattenW   展平W

Less strict version of flatten.
flatten 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const flattenW: <R1, R2, E1, E2, A>(
  mma: ReaderEither<R1, E1, ReaderEither<R2, E2, A>>
) => ReaderEither<R1 & R2, E1 | E2, A>

Added in v2.11.0 v2.11.0 中添加

traversing   穿越

sequenceArray   序列数组

Equivalent to ReadonlyArray#sequence(Applicative). 相当于 ReadonlyArray#sequence(Applicative)

Signature 签名

export declare const sequenceArray: <R, E, A>(arr: readonly ReaderEither<R, E, A>[]) => ReaderEither<R, E, readonly A[]>

Added in v2.9.0 v2.9.0中添加

traverseArray   遍历数组

Equivalent to ReadonlyArray#traverse(Applicative). 相当于 ReadonlyArray#traverse(Applicative)

Signature 签名

export declare const traverseArray: <R, E, A, B>(
  f: (a: A) => ReaderEither<R, E, B>
) => (as: readonly A[]) => ReaderEither<R, E, readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseArrayWithIndex   带索引遍历数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseArrayWithIndex: <R, E, A, B>(
  f: (index: number, a: A) => ReaderEither<R, E, B>
) => (as: readonly A[]) => ReaderEither<R, E, readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseReadonlyArrayWithIndex
遍历带索引的只读数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseReadonlyArrayWithIndex: <A, R, E, B>(
  f: (index: number, a: A) => ReaderEither<R, E, B>
) => (as: readonly A[]) => ReaderEither<R, E, readonly B[]>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyNonEmptyArrayWithIndex
遍历ReadonlyNonEmptyArrayWithIndex

Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(Applicative). 相当于 ReadonlyNonEmptyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseReadonlyNonEmptyArrayWithIndex: <A, R, E, B>(
  f: (index: number, a: A) => ReaderEither<R, E, B>
) => (as: ReadonlyNonEmptyArray<A>) => ReaderEither<R, E, ReadonlyNonEmptyArray<B>>

Added in v2.11.0 v2.11.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'ReaderEither'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

ApT   易于

Signature 签名

export declare const ApT: ReaderEither<unknown, never, readonly []>

Added in v2.11.0 v2.11.0 中添加

ap   美联社

Signature 签名

export declare const ap: <R, E, A>(
  fa: ReaderEither<R, E, A>
) => <B>(fab: ReaderEither<R, E, (a: A) => B>) => ReaderEither<R, E, B>

Added in v2.0.0 v2.0.0 中添加

apFirst   应用程序第一

Combine two effectful actions, keeping only the result of the first.
结合两个有效的操作,仅保留第一个操作的结果。

Signature 签名

export declare const apFirst: <R, E, B>(
  second: ReaderEither<R, E, B>
) => <A>(first: ReaderEither<R, E, A>) => ReaderEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

apFirstW   apFirstW

Less strict version of apFirst
apFirst 的不太严格版本

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const apFirstW: <R2, E2, B>(
  second: ReaderEither<R2, E2, B>
) => <R1, E1, A>(first: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E2 | E1, A>

Added in v2.12.0 v2.12.0 中添加

apSecond   ap秒

Combine two effectful actions, keeping only the result of the second.
结合两个有效的操作,只保留第二个的结果。

Signature 签名

export declare const apSecond: <R, E, B>(
  second: ReaderEither<R, E, B>
) => <A>(first: ReaderEither<R, E, A>) => ReaderEither<R, E, B>

Added in v2.0.0 v2.0.0 中添加

apSecondW   apSecondW

Less strict version of apSecond
apSecond 的不太严格版本

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const apSecondW: <R2, E2, B>(
  second: ReaderEither<R2, E2, B>
) => <R1, E1, A>(first: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E2 | E1, B>

Added in v2.12.0 v2.12.0 中添加

apW   平均功率

Less strict version of ap.
ap 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const apW: <R2, E2, A>(
  fa: ReaderEither<R2, E2, A>
) => <R1, E1, B>(fab: ReaderEither<R1, E1, (a: A) => B>) => ReaderEither<R1 & R2, E2 | E1, B>

Added in v2.8.0 v2.8.0 中添加

local   当地的

Changes the value of the local context during the execution of the action ma (similar to Contravariant’s contramap).
在执行操作 ma 期间更改本地上下文的值(类似于 Contravariantcontramap )。

Signature 签名

export declare const local: <R2, R1>(f: (r2: R2) => R1) => <E, A>(ma: ReaderEither<R1, E, A>) => ReaderEither<R2, E, A>

Added in v2.0.0 v2.0.0 中添加

swap   交换

Signature 签名

export declare const swap: <R, E, A>(ma: ReaderEither<R, E, A>) => ReaderEither<R, A, E>

Added in v2.0.0 v2.0.0 中添加

throwError   抛出错误

Signature 签名

export declare const throwError: <R, E, A>(e: E) => ReaderEither<R, E, A>

Added in v2.7.0 v2.7.0 中添加

zone of death
死亡地带

getApplyMonoid 获取应用Monoid

Use getApplicativeMonoid instead. 请改用 getApplicativeMonoid

Signature 签名

export declare const getApplyMonoid: <R, E, A>(M: Monoid<A>) => Monoid<ReaderEither<R, E, A>>

Added in v2.0.0 v2.0.0 中添加

getApplySemigroup 获取ApplySemigroup

Use getApplySemigroup instead. 请改用 getApplySemigroup

Signature 签名

export declare const getApplySemigroup: <R, E, A>(S: Semigroup<A>) => Semigroup<ReaderEither<R, E, A>>

Added in v2.0.0 v2.0.0 中添加

getReaderValidation 获取读者验证

Use getApplicativeReaderValidation and getAltReaderValidation instead.
请改用 getApplicativeReaderValidationgetAltReaderValidation

Signature 签名

export declare function getReaderValidation<E>(
  SE: Semigroup<E>
): Monad3C<URI, E> & Bifunctor3<URI> & Alt3C<URI, E> & MonadThrow3C<URI, E>

Added in v2.3.0 v2.3.0中添加

getSemigroup 获取半群

Use getApplySemigroup instead. 请改用 getApplySemigroup

Signature 签名

export declare const getSemigroup: <R, E, A>(S: Semigroup<A>) => Semigroup<ReaderEither<R, E, A>>

Added in v2.0.0 v2.0.0 中添加

readerEither 读者要么

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass RE.Functor instead of RE.readerEither (where R is from import R from 'fp-ts/ReaderEither')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 RE.Functor 而不是 RE.readerEither (其中 R 来自 import R from 'fp-ts/ReaderEither'

Signature 签名

export declare const readerEither: Monad3<'ReaderEither'> &
  Bifunctor3<'ReaderEither'> &
  Alt3<'ReaderEither'> &
  MonadThrow3<'ReaderEither'>

Added in v2.0.0 v2.0.0 中添加

ReaderIO overview  ReaderIO 概述

Added in v2.13.0 v2.13.0 中添加


Table of contents
目录


combinators   组合器

tap   轻敲

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tap: {
  <R1, A, R2, _>(self: ReaderIO<R1, A>, f: (a: A) => ReaderIO<R2, _>): ReaderIO<R1 & R2, A>
  <A, R2, _>(f: (a: A) => ReaderIO<R2, _>): <R1>(self: ReaderIO<R1, A>) => ReaderIO<R2 & R1, A>
}

Added in v2.15.0 v2.15.0 中添加

tapIO   tapIO

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapIO: {
  <A, _>(f: (a: A) => I.IO<_>): <R>(self: ReaderIO<R, A>) => ReaderIO<R, A>
  <R, A, _>(self: ReaderIO<R, A>, f: (a: A) => I.IO<_>): ReaderIO<R, A>
}

Example 例子

import { pipe } from 'fp-ts/function'
import * as RIO from 'fp-ts/ReaderIO'
import * as Console from 'fp-ts/Console'

// Will produce `Hello, fp-ts` to the stdout
const effect = pipe(
  RIO.ask<string>(),
  RIO.tapIO((value) => Console.log(`Hello, ${value}`))
)

async function test() {
  assert.deepStrictEqual(effect('fp-ts')(), 'fp-ts')
}

test()

Added in v2.16.0 v2.16.0 中添加

tapReader   点击阅读器

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapReader: {
  <R2, A, _>(f: (a: A) => R.Reader<R2, _>): <R1>(self: ReaderIO<R1, A>) => ReaderIO<R1 & R2, A>
  <R1, A, R2, _>(self: ReaderIO<R1, A>, f: (a: A) => R.Reader<R2, _>): ReaderIO<R1 & R2, A>
}

Added in v2.16.0 v2.16.0 中添加

constructors  构造函数

ask  

Reads the current context.
读取当前上下文。

Signature 签名

export declare const ask: <R>() => ReaderIO<R, R>

Added in v2.13.0 v2.13.0 中添加

asks  

Projects a value from the global context in a ReaderIO.
将全局上下文中的值投影到 ReaderIO 中。

Signature 签名

export declare const asks: <R, A>(f: (r: R) => A) => ReaderIO<R, A>

Added in v2.13.0 v2.13.0 中添加

asksReaderIO   询问ReaderIO

Effectfully accesses the environment.
有效地访问环境。

Signature 签名

export declare const asksReaderIO: <R, A>(f: (r: R) => ReaderIO<R, A>) => ReaderIO<R, A>

Added in v2.13.0 v2.13.0 中添加

asksReaderIOW   询问读者IOW

Less strict version of asksReaderIO.
asksReaderIO 的不太严格版本。

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const asksReaderIOW: <R1, R2, A>(f: (r1: R1) => ReaderIO<R2, A>) => ReaderIO<R1 & R2, A>

Added in v2.13.0 v2.13.0 中添加

of  

Signature 签名

export declare const of: <R = unknown, A = never>(a: A) => ReaderIO<R, A>

Added in v2.13.0 v2.13.0 中添加

conversions   转换

fromIO   来自IO

Signature 签名

export declare const fromIO: <A, R = unknown>(fa: I.IO<A>) => ReaderIO<R, A>

Added in v2.13.0 v2.13.0 中添加

fromReader   来自读者

Signature 签名

export declare const fromReader: <R, A>(fa: R.Reader<R, A>) => ReaderIO<R, A>

Added in v2.13.0 v2.13.0 中添加

do notation   做记号

Do  

Signature 签名

export declare const Do: ReaderIO<unknown, {}>

Added in v2.13.0 v2.13.0 中添加

apS   apS

Signature 签名

export declare const apS: <N, A, E, B>(
  name: Exclude<N, keyof A>,
  fb: ReaderIO<E, B>
) => (fa: ReaderIO<E, A>) => ReaderIO<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.13.0 v2.13.0 中添加

apSW   apSW

Less strict version of apS.
apS 的不太严格版本。

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const apSW: <N extends string, A, R2, B>(
  name: Exclude<N, keyof A>,
  fb: ReaderIO<R2, B>
) => <R1>(fa: ReaderIO<R1, A>) => ReaderIO<R1 & R2, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.13.0 v2.13.0 中添加

bind   绑定

Signature 签名

export declare const bind: <N, A, E, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => ReaderIO<E, B>
) => (ma: ReaderIO<E, A>) => ReaderIO<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.13.0 v2.13.0 中添加

bindTo   绑定到

Signature 签名

export declare const bindTo: <N>(name: N) => <E, A>(fa: ReaderIO<E, A>) => ReaderIO<E, { readonly [K in N]: A }>

Added in v2.13.0 v2.13.0 中添加

bindW   绑定W

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const bindW: <N extends string, A, R2, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => ReaderIO<R2, B>
) => <R1>(fa: ReaderIO<R1, A>) => ReaderIO<R1 & R2, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.13.0 v2.13.0 中添加

instances   实例

Applicative   适用性

Signature 签名

export declare const Applicative: Applicative2<'ReaderIO'>

Added in v2.13.0 v2.13.0 中添加

Apply   申请

Signature 签名

export declare const Apply: Apply2<'ReaderIO'>

Added in v2.13.0 v2.13.0 中添加

Chain  

Signature 签名

export declare const Chain: chainable.Chain2<'ReaderIO'>

Added in v2.13.0 v2.13.0 中添加

FromIO   来自IO

Signature 签名

export declare const FromIO: FromIO2<'ReaderIO'>

Added in v2.13.0 v2.13.0 中添加

FromReader   来自读者

Signature 签名

export declare const FromReader: FromReader2<'ReaderIO'>

Added in v2.13.0 v2.13.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor2<'ReaderIO'>

Added in v2.13.0 v2.13.0 中添加

Monad   单子

Signature 签名

export declare const Monad: Monad2<'ReaderIO'>

Added in v2.13.0 v2.13.0 中添加

MonadIO   莫纳德奥

Signature 签名

export declare const MonadIO: MonadIO2<'ReaderIO'>

Added in v2.13.0 v2.13.0 中添加

Pointed  

Signature 签名

export declare const Pointed: Pointed2<'ReaderIO'>

Added in v2.13.0 v2.13.0 中添加

legacy   遗产

chain  

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chain: <A, R, B>(f: (a: A) => ReaderIO<R, B>) => (ma: ReaderIO<R, A>) => ReaderIO<R, B>

Added in v2.13.0 v2.13.0 中添加

chainFirst   链优先

Alias of tap.  tap 的别名。

Signature 签名

export declare const chainFirst: <A, R, B>(f: (a: A) => ReaderIO<R, B>) => (first: ReaderIO<R, A>) => ReaderIO<R, A>

Added in v2.13.0 v2.13.0 中添加

chainFirstIOK  链第一IOK

Alias of tapIO.  tapIO 的别名。

Signature 签名

export declare const chainFirstIOK: <A, B>(f: (a: A) => I.IO<B>) => <E>(first: ReaderIO<E, A>) => ReaderIO<E, A>

Added in v2.13.0 v2.13.0 中添加

chainFirstReaderK  链第一读者K

Alias of tapReader.  tapReader 的别名。

Signature 签名

export declare const chainFirstReaderK: <A, R, B>(f: (a: A) => R.Reader<R, B>) => (ma: ReaderIO<R, A>) => ReaderIO<R, A>

Added in v2.13.0 v2.13.0 中添加

chainFirstReaderKW  chainFirstReaderKW

Alias of tapReader.  tapReader 的别名。

Less strict version of chainFirstReaderK.
chainFirstReaderK 的不太严格版本。

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const chainFirstReaderKW: <A, R1, B>(
  f: (a: A) => R.Reader<R1, B>
) => <R2>(ma: ReaderIO<R2, A>) => ReaderIO<R1 & R2, A>

Added in v2.13.0 v2.13.0 中添加

chainFirstW  链优先W

Alias of tap.  tap 的别名。

Signature 签名

export declare const chainFirstW: <A, R2, B>(
  f: (a: A) => ReaderIO<R2, B>
) => <R1>(ma: ReaderIO<R1, A>) => ReaderIO<R1 & R2, A>

Added in v2.13.0 v2.13.0 中添加

chainIOK  链IOK

Alias of flatMapIO.  flatMapIO 的别名。

Signature 签名

export declare const chainIOK: <A, B>(f: (a: A) => I.IO<B>) => <E>(first: ReaderIO<E, A>) => ReaderIO<E, B>

Added in v2.13.0 v2.13.0 中添加

chainReaderK  链读器K

Alias of flatMapReader.  flatMapReader 的别名。

Signature 签名

export declare const chainReaderK: <A, R, B>(f: (a: A) => R.Reader<R, B>) => (ma: ReaderIO<R, A>) => ReaderIO<R, B>

Added in v2.13.0 v2.13.0 中添加

chainReaderKW  链式阅读器KW

Alias of flatMapReader.  flatMapReader 的别名。

Less strict version of chainReaderK.
chainReaderK 的不太严格版本。

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const chainReaderKW: <A, R1, B>(
  f: (a: A) => R.Reader<R1, B>
) => <R2>(ma: ReaderIO<R2, A>) => ReaderIO<R1 & R2, B>

Added in v2.13.0 v2.13.0 中添加

chainW   链W

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chainW: <A, R2, B>(
  f: (a: A) => ReaderIO<R2, B>
) => <R1>(ma: ReaderIO<R1, A>) => ReaderIO<R1 & R2, B>

Added in v2.13.0 v2.13.0 中添加

lifting   起重

fromIOK   来自IOK

Signature 签名

export declare const fromIOK: <A extends readonly unknown[], B>(
  f: (...a: A) => I.IO<B>
) => <R = unknown>(...a: A) => ReaderIO<R, B>

Added in v2.13.0 v2.13.0 中添加

fromReaderK   来自ReaderK

Signature 签名

export declare const fromReaderK: <A extends readonly unknown[], R, B>(
  f: (...a: A) => R.Reader<R, B>
) => (...a: A) => ReaderIO<R, B>

Added in v2.13.0 v2.13.0 中添加

mapping   映射

as   作为

Maps the value to the specified constant value.
将值映射到指定的常量值。

Signature 签名

export declare const as: {
  <A>(a: A): <R, _>(self: ReaderIO<R, _>) => ReaderIO<R, A>
  <R, _, A>(self: ReaderIO<R, _>, a: A): ReaderIO<R, A>
}

Added in v2.16.0 v2.16.0 中添加

asUnit   作为单位

Maps the value to the void constant value.
将值映射到 void 常量值。

Signature 签名

export declare const asUnit: <R, _>(self: ReaderIO<R, _>) => ReaderIO<R, void>

Added in v2.16.0 v2.16.0 中添加

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <E, B>(fab: ReaderIO<E, (a: A) => B>) => ReaderIO<E, B>

Added in v2.13.0 v2.13.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => <R>(fa: ReaderIO<R, A>) => ReaderIO<R, B>

Added in v2.13.0 v2.13.0 中添加

model   模型

ReaderIO (interface)   ReaderIO(接口)

Signature 签名

export interface ReaderIO<R, A> {
  (r: R): I.IO<A>
}

Added in v2.13.0 v2.13.0 中添加

sequencing   测序

flatMap   平面地图

Signature 签名

export declare const flatMap: {
  <A, R2, B>(f: (a: A) => ReaderIO<R2, B>): <R1>(ma: ReaderIO<R1, A>) => ReaderIO<R1 & R2, B>
  <R1, A, R2, B>(ma: ReaderIO<R1, A>, f: (a: A) => ReaderIO<R2, B>): ReaderIO<R1 & R2, B>
}

Added in v2.14.0 v2.14.0 中添加

flatMapIO   平面MapIO

Signature 签名

export declare const flatMapIO: {
  <A, B>(f: (a: A) => I.IO<B>): <R>(self: ReaderIO<R, A>) => ReaderIO<R, B>
  <R, A, B>(self: ReaderIO<R, A>, f: (a: A) => I.IO<B>): ReaderIO<R, B>
}

Added in v2.16.0 v2.16.0 中添加

flatMapReader   平面地图阅读器

Signature 签名

export declare const flatMapReader: {
  <A, R2, B>(f: (a: A) => R.Reader<R2, B>): <R1>(self: ReaderIO<R1, A>) => ReaderIO<R1 & R2, B>
  <R1, A, R2, B>(self: ReaderIO<R1, A>, f: (a: A) => R.Reader<R2, B>): ReaderIO<R1 & R2, B>
}

Added in v2.16.0 v2.16.0 中添加

flatten   压扁

Signature 签名

export declare const flatten: <R, A>(mma: ReaderIO<R, ReaderIO<R, A>>) => ReaderIO<R, A>

Added in v2.13.0 v2.13.0 中添加

flattenW   展平W

Less strict version of flatten.
flatten 的不太严格版本。

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const flattenW: <R1, R2, A>(mma: ReaderIO<R1, ReaderIO<R2, A>>) => ReaderIO<R1 & R2, A>

Added in v2.13.0 v2.13.0 中添加

traversing   穿越

sequenceArray   序列数组

Equivalent to ReadonlyArray#sequence(Applicative). 相当于 ReadonlyArray#sequence(Applicative)

Signature 签名

export declare const sequenceArray: <R, A>(arr: readonly ReaderIO<R, A>[]) => ReaderIO<R, readonly A[]>

Added in v2.13.0 v2.13.0 中添加

traverseArray   遍历数组

Equivalent to ReadonlyArray#traverse(Applicative). 相当于 ReadonlyArray#traverse(Applicative)

Signature 签名

export declare const traverseArray: <A, R, B>(
  f: (a: A) => ReaderIO<R, B>
) => (as: readonly A[]) => ReaderIO<R, readonly B[]>

Added in v2.13.0 v2.13.0 中添加

traverseArrayWithIndex   带索引遍历数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseArrayWithIndex: <A, R, B>(
  f: (index: number, a: A) => ReaderIO<R, B>
) => (as: readonly A[]) => ReaderIO<R, readonly B[]>

Added in v2.13.0 v2.13.0 中添加

traverseReadonlyArrayWithIndex
遍历带索引的只读数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseReadonlyArrayWithIndex: <A, R, B>(
  f: (index: number, a: A) => ReaderIO<R, B>
) => (as: readonly A[]) => ReaderIO<R, readonly B[]>

Added in v2.13.0 v2.13.0 中添加

traverseReadonlyNonEmptyArrayWithIndex
遍历ReadonlyNonEmptyArrayWithIndex

Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(Applicative). 相当于 ReadonlyNonEmptyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseReadonlyNonEmptyArrayWithIndex: <A, R, B>(
  f: (index: number, a: A) => ReaderIO<R, B>
) => (as: ReadonlyNonEmptyArray<A>) => ReaderIO<R, ReadonlyNonEmptyArray<B>>

Added in v2.13.0 v2.13.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'ReaderIO'

Added in v2.13.0 v2.13.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.13.0 v2.13.0 中添加

utils   实用程序

ApT   易于

Signature 签名

export declare const ApT: ReaderIO<unknown, readonly []>

Added in v2.13.0 v2.13.0 中添加

ap   美联社

Signature 签名

export declare const ap: <R, A>(fa: ReaderIO<R, A>) => <B>(fab: ReaderIO<R, (a: A) => B>) => ReaderIO<R, B>

Added in v2.13.0 v2.13.0 中添加

apFirst   应用程序第一

Combine two effectful actions, keeping only the result of the first.
结合两个有效的操作,仅保留第一个操作的结果。

Signature 签名

export declare const apFirst: <E, B>(second: ReaderIO<E, B>) => <A>(first: ReaderIO<E, A>) => ReaderIO<E, A>

Added in v2.13.0 v2.13.0 中添加

apSecond   ap秒

Combine two effectful actions, keeping only the result of the second.
结合两个有效的操作,只保留第二个的结果。

Signature 签名

export declare const apSecond: <E, B>(second: ReaderIO<E, B>) => <A>(first: ReaderIO<E, A>) => ReaderIO<E, B>

Added in v2.13.0 v2.13.0 中添加

apW   平均功率

Less strict version of ap.
ap 的不太严格版本。

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const apW: <R2, A>(
  fa: ReaderIO<R2, A>
) => <R1, B>(fab: ReaderIO<R1, (a: A) => B>) => ReaderIO<R1 & R2, B>

Added in v2.13.0 v2.13.0 中添加

local   当地的

Changes the value of the local context during the execution of the action ma (similar to Contravariant’s contramap).
在执行操作 ma 期间更改本地上下文的值(类似于 Contravariantcontramap )。

Signature 签名

export declare const local: <R2, R1>(f: (r2: R2) => R1) => <A>(ma: ReaderIO<R1, A>) => ReaderIO<R2, A>

Added in v2.13.0 v2.13.0 中添加

ReaderT overview  ReaderT概述

The reader monad transformer, which adds a read-only environment to the given monad.
reader monad 转换器,为给定的 monad 添加只读环境。

The of function ignores the environment, while chain passes the inherited environment to both subcomputations.
of 函数忽略环境,而 chain 将继承的环境传递给两个子计算。

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


constructors  构造函数

fromNaturalTransformation
从自然转变

Signature 签名

export declare function fromNaturalTransformation<F extends URIS2, G extends URIS4>(
  nt: NaturalTransformation24S<F, G>
): <R, S, A, E>(f: (r: R) => Kind2<F, S, A>) => Reader<R, Kind4<G, S, R, E, A>>
export declare function fromNaturalTransformation<F extends URIS2, G extends URIS3>(
  nt: NaturalTransformation23R<F, G>
): <R, A, E>(f: (r: R) => Kind2<F, R, A>) => Reader<R, Kind3<G, R, E, A>>
export declare function fromNaturalTransformation<F extends URIS2, G extends URIS2>(
  nt: NaturalTransformation22<F, G>
): <R, E, A>(f: (r: R) => Kind2<F, E, A>) => Reader<R, Kind2<G, E, A>>
export declare function fromNaturalTransformation<F extends URIS, G extends URIS2>(
  nt: NaturalTransformation12<F, G>
): <R, A, E>(f: (r: R) => Kind<F, A>) => Reader<R, Kind2<G, E, A>>
export declare function fromNaturalTransformation<F extends URIS, G extends URIS>(
  nt: NaturalTransformation11<F, G>
): <R, A>(f: (r: R) => Kind<F, A>) => Reader<R, Kind<G, A>>
export declare function fromNaturalTransformation<F, G>(
  nt: NaturalTransformation<F, G>
): <R, A>(f: (r: R) => HKT<F, A>) => Reader<R, HKT<G, A>>

Added in v2.11.0 v2.11.0 中添加

utils   实用程序

ap   美联社

Signature 签名

export declare function ap<F extends URIS4>(
  F: Apply4<F>
): <R, S, FR, FE, A>(
  fa: Reader<R, Kind4<F, S, FR, FE, A>>
) => <B>(fab: Reader<R, Kind4<F, S, FR, FE, (a: A) => B>>) => Reader<R, Kind4<F, S, FR, FE, B>>
export declare function ap<F extends URIS3>(
  F: Apply3<F>
): <R, FR, FE, A>(
  fa: Reader<R, Kind3<F, FR, FE, A>>
) => <B>(fab: Reader<R, Kind3<F, FR, FE, (a: A) => B>>) => Reader<R, Kind3<F, FR, FE, B>>
export declare function ap<F extends URIS3, FE>(
  F: Apply3C<F, FE>
): <R, FR, A>(
  fa: Reader<R, Kind3<F, FR, FE, A>>
) => <B>(fab: Reader<R, Kind3<F, FR, FE, (a: A) => B>>) => Reader<R, Kind3<F, FR, FE, B>>
export declare function ap<F extends URIS2>(
  F: Apply2<F>
): <R, FE, A>(
  fa: Reader<R, Kind2<F, FE, A>>
) => <B>(fab: Reader<R, Kind2<F, FE, (a: A) => B>>) => Reader<R, Kind2<F, FE, B>>
export declare function ap<F extends URIS2, FE>(
  F: Apply2C<F, FE>
): <R, A>(
  fa: Reader<R, Kind2<F, FE, A>>
) => <B>(fab: Reader<R, Kind2<F, FE, (a: A) => B>>) => Reader<R, Kind2<F, FE, B>>
export declare function ap<F extends URIS>(
  F: Apply1<F>
): <R, A>(fa: Reader<R, Kind<F, A>>) => <B>(fab: Reader<R, Kind<F, (a: A) => B>>) => Reader<R, Kind<F, B>>
export declare function ap<F>(
  F: Apply<F>
): <R, A>(fa: Reader<R, HKT<F, A>>) => <B>(fab: Reader<R, HKT<F, (a: A) => B>>) => Reader<R, HKT<F, B>>

Added in v2.10.0 v2.10.0 中添加

chain  

Signature 签名

export declare function chain<M extends URIS4>(
  M: Chain4<M>
): <A, R, S, FR, FE, B>(
  f: (a: A) => Reader<R, Kind4<M, S, FR, FE, B>>
) => (ma: Reader<R, Kind4<M, S, FR, FE, A>>) => Reader<R, Kind4<M, S, FR, FE, B>>
export declare function chain<M extends URIS3>(
  M: Chain3<M>
): <A, R, FR, FE, B>(
  f: (a: A) => Reader<R, Kind3<M, FR, FE, B>>
) => (ma: Reader<R, Kind3<M, FR, FE, A>>) => Reader<R, Kind3<M, FR, FE, B>>
export declare function chain<M extends URIS3, FE>(
  M: Chain3C<M, FE>
): <A, R, FR, B>(
  f: (a: A) => Reader<R, Kind3<M, FR, FE, B>>
) => (ma: Reader<R, Kind3<M, FR, FE, A>>) => Reader<R, Kind3<M, FR, FE, B>>
export declare function chain<M extends URIS2>(
  M: Chain2<M>
): <A, R, FE, B>(
  f: (a: A) => Reader<R, Kind2<M, FE, B>>
) => (ma: Reader<R, Kind2<M, FE, A>>) => Reader<R, Kind2<M, FE, B>>
export declare function chain<M extends URIS2, FE>(
  M: Chain2C<M, FE>
): <A, R, B>(f: (a: A) => Reader<R, Kind2<M, FE, B>>) => (ma: Reader<R, Kind2<M, FE, A>>) => Reader<R, Kind2<M, FE, B>>
export declare function chain<M extends URIS>(
  M: Chain1<M>
): <A, R, B>(f: (a: A) => Reader<R, Kind<M, B>>) => (ma: Reader<R, Kind<M, A>>) => Reader<R, Kind<M, B>>
export declare function chain<M>(
  M: Chain<M>
): <A, R, B>(f: (a: A) => Reader<R, HKT<M, B>>) => (ma: Reader<R, HKT<M, A>>) => Reader<R, HKT<M, B>>

Added in v2.10.0 v2.10.0 中添加

fromReader   来自读者

Signature 签名

export declare function fromReader<F extends URIS4>(
  F: Pointed4<F>
): <R, A, S, FR, FE>(ma: Reader<R, A>) => Reader<R, Kind4<F, S, FR, FE, A>>
export declare function fromReader<F extends URIS3>(
  F: Pointed3<F>
): <R, A, FR, FE>(ma: Reader<R, A>) => Reader<R, Kind3<F, FR, FE, A>>
export declare function fromReader<F extends URIS3, FE>(
  F: Pointed3C<F, FE>
): <R, A, FR>(ma: Reader<R, A>) => Reader<R, Kind3<F, FR, FE, A>>
export declare function fromReader<F extends URIS2>(
  F: Pointed2<F>
): <R, A, FE>(ma: Reader<R, A>) => Reader<R, Kind2<F, FE, A>>
export declare function fromReader<F extends URIS2, FE>(
  F: Pointed2C<F, FE>
): <R, A>(ma: Reader<R, A>) => Reader<R, Kind2<F, FE, A>>
export declare function fromReader<F extends URIS>(F: Pointed1<F>): <R, A>(ma: Reader<R, A>) => Reader<R, Kind<F, A>>
export declare function fromReader<F>(F: Pointed<F>): <R, A>(ma: Reader<R, A>) => Reader<R, HKT<F, A>>

Added in v2.10.0 v2.10.0 中添加

map   地图

Signature 签名

export declare function map<F extends URIS4>(
  F: Functor4<F>
): <A, B>(f: (a: A) => B) => <R, S, FR, FE>(fa: Reader<R, Kind4<F, S, FR, FE, A>>) => Reader<R, Kind4<F, S, FR, FE, B>>
export declare function map<F extends URIS3>(
  F: Functor3<F>
): <A, B>(f: (a: A) => B) => <R, FR, FE>(fa: Reader<R, Kind3<F, FR, FE, A>>) => Reader<R, Kind3<F, FR, FE, B>>
export declare function map<F extends URIS3, FE>(
  F: Functor3C<F, FE>
): <A, B>(f: (a: A) => B) => <R, FR>(fa: Reader<R, Kind3<F, FR, FE, A>>) => Reader<R, Kind3<F, FR, FE, B>>
export declare function map<F extends URIS2>(
  F: Functor2<F>
): <A, B>(f: (a: A) => B) => <R, FE>(fa: Reader<R, Kind2<F, FE, A>>) => Reader<R, Kind2<F, FE, B>>
export declare function map<F extends URIS2, FE>(
  F: Functor2C<F, FE>
): <A, B>(f: (a: A) => B) => <R>(fa: Reader<R, Kind2<F, FE, A>>) => Reader<R, Kind2<F, FE, B>>
export declare function map<F extends URIS>(
  F: Functor1<F>
): <A, B>(f: (a: A) => B) => <R>(fa: Reader<R, Kind<F, A>>) => Reader<R, Kind<F, B>>
export declare function map<F>(
  F: Functor<F>
): <A, B>(f: (a: A) => B) => <R>(fa: Reader<R, HKT<F, A>>) => Reader<R, HKT<F, B>>

Added in v2.10.0 v2.10.0 中添加

of  

Signature 签名

export declare function of<F extends URIS4>(
  F: Pointed4<F>
): <A, R, S, FR, FE>(a: A) => Reader<R, Kind4<F, S, FR, FE, A>>
export declare function of<F extends URIS3>(F: Pointed3<F>): <A, R, FR, FE>(a: A) => Reader<R, Kind3<F, FR, FE, A>>
export declare function of<F extends URIS3, FE>(F: Pointed3C<F, FE>): <A, R, FR>(a: A) => Reader<R, Kind3<F, FR, FE, A>>
export declare function of<F extends URIS2>(F: Pointed2<F>): <A, R, FE>(a: A) => Reader<R, Kind2<F, FE, A>>
export declare function of<F extends URIS2, FE>(F: Pointed2C<F, FE>): <A, R>(a: A) => Reader<R, Kind2<F, FE, A>>
export declare function of<F extends URIS>(F: Pointed1<F>): <A, R>(a: A) => Reader<R, Kind<F, A>>
export declare function of<F>(F: Pointed<F>): <A, R>(a: A) => Reader<R, HKT<F, A>>

Added in v2.10.0 v2.10.0 中添加

zone of death
死亡地带

ReaderM1 读者M1 (interface)   (界面)

Signature 签名

export interface ReaderM1<M extends URIS> {
  readonly map: <R, A, B>(ma: ReaderT1<M, R, A>, f: (a: A) => B) => ReaderT1<M, R, B>
  readonly of: <R, A>(a: A) => ReaderT1<M, R, A>
  readonly ap: <R, A, B>(mab: ReaderT1<M, R, (a: A) => B>, ma: ReaderT1<M, R, A>) => ReaderT1<M, R, B>
  readonly chain: <R, A, B>(ma: ReaderT1<M, R, A>, f: (a: A) => ReaderT1<M, R, B>) => ReaderT1<M, R, B>
  readonly ask: <R>() => ReaderT1<M, R, R>
  readonly asks: <R, A>(f: (r: R) => A) => ReaderT1<M, R, A>
  readonly local: <R1, A, R2>(ma: ReaderT1<M, R1, A>, f: (d: R2) => R1) => ReaderT1<M, R2, A>
  readonly fromReader: <R, A>(ma: Reader<R, A>) => ReaderT1<M, R, A>
  readonly fromM: <R, A>(ma: Kind<M, A>) => ReaderT1<M, R, A>
}

Added in v2.0.0 v2.0.0 中添加

ReaderM2C 读者M2C (interface)   (界面)

Signature 签名

export interface ReaderM2C<M extends URIS2, E> {
  readonly map: <R, A, B>(ma: ReaderT2<M, R, E, A>, f: (a: A) => B) => ReaderT2<M, R, E, B>
  readonly of: <R, A>(a: A) => ReaderT2<M, R, E, A>
  readonly ap: <R, A, B>(mab: ReaderT2<M, R, E, (a: A) => B>, ma: ReaderT2<M, R, E, A>) => ReaderT2<M, R, E, B>
  readonly chain: <R, A, B>(ma: ReaderT2<M, R, E, A>, f: (a: A) => ReaderT2<M, R, E, B>) => ReaderT2<M, R, E, B>
  readonly ask: <R>() => ReaderT2<M, R, E, R>
  readonly asks: <R, A>(f: (r: R) => A) => ReaderT2<M, R, E, A>
  readonly local: <R1, A, R2>(ma: ReaderT2<M, R1, E, A>, f: (d: R2) => R1) => ReaderT2<M, R2, E, A>
  readonly fromReader: <R, A>(ma: Reader<R, A>) => ReaderT2<M, R, E, A>
  readonly fromM: <R, A>(ma: Kind2<M, E, A>) => ReaderT2<M, R, E, A>
}

Added in v2.2.0 v2.2.0中添加

ReaderM2 读者M2 (interface)   (界面)

Signature 签名

export interface ReaderM2<M extends URIS2> {
  readonly map: <R, E, A, B>(ma: ReaderT2<M, R, E, A>, f: (a: A) => B) => ReaderT2<M, R, E, B>
  readonly of: <R, E, A>(a: A) => ReaderT2<M, R, E, A>
  readonly ap: <R, E, A, B>(mab: ReaderT2<M, R, E, (a: A) => B>, ma: ReaderT2<M, R, E, A>) => ReaderT2<M, R, E, B>
  readonly chain: <R, E, A, B>(ma: ReaderT2<M, R, E, A>, f: (a: A) => ReaderT2<M, R, E, B>) => ReaderT2<M, R, E, B>
  readonly ask: <R, E>() => ReaderT2<M, R, E, R>
  readonly asks: <R, E, A>(f: (r: R) => A) => ReaderT2<M, R, E, A>
  readonly local: <R1, E, A, R2>(ma: ReaderT2<M, R1, E, A>, f: (d: R2) => R1) => ReaderT2<M, R2, E, A>
  readonly fromReader: <R, E, A>(ma: Reader<R, A>) => ReaderT2<M, R, E, A>
  readonly fromM: <R, E, A>(ma: Kind2<M, E, A>) => ReaderT2<M, R, E, A>
}

Added in v2.0.0 v2.0.0 中添加

ReaderM3 读者M3 (interface)   (界面)

Signature 签名

export interface ReaderM3<M extends URIS3> {
  readonly map: <R, U, E, A, B>(ma: ReaderT3<M, R, U, E, A>, f: (a: A) => B) => ReaderT3<M, R, U, E, B>
  readonly of: <R, U, E, A>(a: A) => ReaderT3<M, R, U, E, A>
  readonly ap: <R, U, E, A, B>(
    mab: ReaderT3<M, R, U, E, (a: A) => B>,
    ma: ReaderT3<M, R, U, E, A>
  ) => ReaderT3<M, R, U, E, B>
  readonly chain: <R, U, E, A, B>(
    ma: ReaderT3<M, R, U, E, A>,
    f: (a: A) => ReaderT3<M, R, U, E, B>
  ) => ReaderT3<M, R, U, E, B>
  readonly ask: <R, U, E>() => ReaderT3<M, R, U, E, R>
  readonly asks: <R, U, E, A>(f: (r: R) => A) => ReaderT3<M, R, U, E, A>
  readonly local: <R1, U, E, A, R2>(ma: ReaderT3<M, R1, U, E, A>, f: (d: R2) => R1) => ReaderT3<M, R2, U, E, A>
  readonly fromReader: <R, U, E, A>(ma: Reader<R, A>) => ReaderT3<M, R, U, E, A>
  readonly fromM: <R, U, E, A>(ma: Kind3<M, U, E, A>) => ReaderT3<M, R, U, E, A>
}

Added in v2.0.0 v2.0.0 中添加

ReaderM 读者M (interface)   (界面)

Signature 签名

export interface ReaderM<M> {
  readonly map: <R, A, B>(ma: ReaderT<M, R, A>, f: (a: A) => B) => ReaderT<M, R, B>
  readonly of: <R, A>(a: A) => ReaderT<M, R, A>
  readonly ap: <R, A, B>(mab: ReaderT<M, R, (a: A) => B>, ma: ReaderT<M, R, A>) => ReaderT<M, R, B>
  readonly chain: <R, A, B>(ma: ReaderT<M, R, A>, f: (a: A) => ReaderT<M, R, B>) => ReaderT<M, R, B>
  readonly ask: <R>() => ReaderT<M, R, R>
  readonly asks: <R, A>(f: (r: R) => A) => ReaderT<M, R, A>
  readonly local: <R1, A, R2>(ma: ReaderT<M, R1, A>, f: (d: R2) => R1) => ReaderT<M, R2, A>
  readonly fromReader: <R, A>(ma: Reader<R, A>) => ReaderT<M, R, A>
  readonly fromM: <R, A>(ma: HKT<M, A>) => ReaderT<M, R, A>
}

Added in v2.0.0 v2.0.0 中添加

ReaderT1 读者T1 (interface)   (界面)

Signature 签名

export interface ReaderT1<M extends URIS, R, A> {
  (r: R): Kind<M, A>
}

Added in v2.0.0 v2.0.0 中添加

ReaderT2 读者T2 (interface)   (界面)

Signature 签名

export interface ReaderT2<M extends URIS2, R, E, A> {
  (r: R): Kind2<M, E, A>
}

Added in v2.0.0 v2.0.0 中添加

ReaderT3 读者T3 (interface)   (界面)

Signature 签名

export interface ReaderT3<M extends URIS3, R, U, E, A> {
  (r: R): Kind3<M, U, E, A>
}

Added in v2.0.0 v2.0.0 中添加

ReaderT 读者T (interface)   (界面)

Signature 签名

export interface ReaderT<M, R, A> {
  (r: R): HKT<M, A>
}

Added in v2.0.0 v2.0.0 中添加

getReaderM 获取ReaderM

Signature 签名

export declare function getReaderM<M extends URIS3>(M: Monad3<M>): ReaderM3<M>
export declare function getReaderM<M extends URIS2>(M: Monad2<M>): ReaderM2<M>
export declare function getReaderM<M extends URIS2, E>(M: Monad2C<M, E>): ReaderM2C<M, E>
export declare function getReaderM<M extends URIS>(M: Monad1<M>): ReaderM1<M>
export declare function getReaderM<M>(M: Monad<M>): ReaderM<M>

Added in v2.0.0 v2.0.0 中添加

ReaderTask overview  Reader任务概述

Added in v2.3.0 v2.3.0中添加


Table of contents
目录


combinators   组合器

tap   轻敲

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tap: {
  <R1, A, R2, _>(self: ReaderTask<R1, A>, f: (a: A) => ReaderTask<R2, _>): ReaderTask<R1 & R2, A>
  <A, R2, _>(f: (a: A) => ReaderTask<R2, _>): <R1>(self: ReaderTask<R1, A>) => ReaderTask<R2 & R1, A>
}

Added in v2.15.0 v2.15.0 中添加

tapIO   tapIO

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapIO: {
  <A, _>(f: (a: A) => IO<_>): <R>(self: ReaderTask<R, A>) => ReaderTask<R, A>
  <R, A, _>(self: ReaderTask<R, A>, f: (a: A) => IO<_>): ReaderTask<R, A>
}

Example 例子

import { pipe } from 'fp-ts/function'
import * as RT from 'fp-ts/ReaderTask'
import * as Console from 'fp-ts/Console'

// Will produce `Hello, fp-ts` to the stdout
const effect = pipe(
  RT.ask<string>(),
  RT.tapIO((value) => Console.log(`Hello, ${value}`))
)

async function test() {
  assert.deepStrictEqual(await effect('fp-ts')(), 'fp-ts')
}

test()

Added in v2.16.0 v2.16.0 中添加

tapReader   点击阅读器

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapReader: {
  <R2, A, _>(f: (a: A) => R.Reader<R2, _>): <R1>(self: ReaderTask<R1, A>) => ReaderTask<R1 & R2, A>
  <R1, R2, A, _>(self: ReaderTask<R1, A>, f: (a: A) => R.Reader<R2, _>): ReaderTask<R1 & R2, A>
}

Added in v2.16.0 v2.16.0 中添加

tapReaderIO   TapReaderIO

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapReaderIO: {
  <R2, A, _>(f: (a: A) => RIO.ReaderIO<R2, _>): <R1>(self: ReaderTask<R1, A>) => ReaderTask<R1 & R2, A>
  <R1, R2, A, _>(self: ReaderTask<R1, A>, f: (a: A) => RIO.ReaderIO<R2, _>): ReaderTask<R1 & R2, A>
}

Added in v2.16.0 v2.16.0 中添加

tapTask   点击任务

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapTask: {
  <A, _>(f: (a: A) => T.Task<_>): <R>(self: ReaderTask<R, A>) => ReaderTask<R, A>
  <R, A, _>(self: ReaderTask<R, A>, f: (a: A) => T.Task<_>): ReaderTask<R, A>
}

Example 例子

import { pipe } from 'fp-ts/function'
import * as RT from 'fp-ts/ReaderTask'
import * as T from 'fp-ts/Task'

const effect = pipe(
  RT.ask<number>(),
  RT.tapTask((value) => T.of(value + 1))
)

async function test() {
  assert.deepStrictEqual(await effect(1)(), 1)
}

test()

Added in v2.16.0 v2.16.0 中添加

constructors  构造函数

ask  

Reads the current context.
读取当前上下文。

Signature 签名

export declare const ask: <R>() => ReaderTask<R, R>

Added in v2.3.0 v2.3.0中添加

asks  

Projects a value from the global context in a ReaderTask.
将全局上下文中的值投影到 ReaderTask 中。

Signature 签名

export declare const asks: <R, A>(f: (r: R) => A) => ReaderTask<R, A>

Added in v2.3.0 v2.3.0中添加

asksReaderTask   询问读者任务

Effectfully accesses the environment.
有效地访问环境。

Signature 签名

export declare const asksReaderTask: <R, A>(f: (r: R) => ReaderTask<R, A>) => ReaderTask<R, A>

Added in v2.11.0 v2.11.0 中添加

asksReaderTaskW   询问读者任务

Less strict version of asksReaderTask.
asksReaderTask 的不太严格版本。

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const asksReaderTaskW: <R1, R2, A>(f: (r1: R1) => ReaderTask<R2, A>) => ReaderTask<R1 & R2, A>

Added in v2.11.0 v2.11.0 中添加

of  

Signature 签名

export declare const of: <R = unknown, A = never>(a: A) => ReaderTask<R, A>

Added in v2.3.0 v2.3.0中添加

conversions   转换

fromIO   来自IO

Signature 签名

export declare const fromIO: <A, R = unknown>(fa: IO<A>) => ReaderTask<R, A>

Added in v2.3.0 v2.3.0中添加

fromReader   来自读者

Signature 签名

export declare const fromReader: <R, A>(fa: R.Reader<R, A>) => ReaderTask<R, A>

Added in v2.3.0 v2.3.0中添加

fromReaderIO   来自ReaderIO

Signature 签名

export declare const fromReaderIO: <R, A>(fa: RIO.ReaderIO<R, A>) => ReaderTask<R, A>

Added in v2.13.0 v2.13.0 中添加

fromTask   来自任务

Signature 签名

export declare const fromTask: <A, R = unknown>(fa: T.Task<A>) => ReaderTask<R, A>

Added in v2.3.0 v2.3.0中添加

do notation   做记号

Do  

Signature 签名

export declare const Do: ReaderTask<unknown, {}>

Added in v2.9.0 v2.9.0中添加

apS   apS

Signature 签名

export declare const apS: <N, A, E, B>(
  name: Exclude<N, keyof A>,
  fb: ReaderTask<E, B>
) => (fa: ReaderTask<E, A>) => ReaderTask<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

apSW   apSW

Less strict version of apS.
apS 的不太严格版本。

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const apSW: <A, N extends string, R2, B>(
  name: Exclude<N, keyof A>,
  fb: ReaderTask<R2, B>
) => <R1>(fa: ReaderTask<R1, A>) => ReaderTask<R1 & R2, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bind   绑定

Signature 签名

export declare const bind: <N, A, E, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => ReaderTask<E, B>
) => (ma: ReaderTask<E, A>) => ReaderTask<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bindTo   绑定到

Signature 签名

export declare const bindTo: <N>(name: N) => <E, A>(fa: ReaderTask<E, A>) => ReaderTask<E, { readonly [K in N]: A }>

Added in v2.8.0 v2.8.0 中添加

bindW   绑定W

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const bindW: <N extends string, A, R2, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => ReaderTask<R2, B>
) => <R1>(fa: ReaderTask<R1, A>) => ReaderTask<R1 & R2, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

let  

Signature 签名

export declare const let: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => <E>(fa: ReaderTask<E, A>) => ReaderTask<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.13.0 v2.13.0 中添加

instances   实例

ApplicativePar   应用性参数

Runs computations in parallel.
并行运行计算。

Signature 签名

export declare const ApplicativePar: Applicative2<'ReaderTask'>

Added in v2.7.0 v2.7.0 中添加

ApplicativeSeq   应用序列

Runs computations sequentially.
按顺序运行计算。

Signature 签名

export declare const ApplicativeSeq: Applicative2<'ReaderTask'>

Added in v2.7.0 v2.7.0 中添加

ApplyPar   申请帕

Runs computations in parallel.
并行运行计算。

Signature 签名

export declare const ApplyPar: Apply2<'ReaderTask'>

Added in v2.10.0 v2.10.0 中添加

ApplySeq   应用序列

Runs computations sequentially.
按顺序运行计算。

Signature 签名

export declare const ApplySeq: Apply2<'ReaderTask'>

Added in v2.10.0 v2.10.0 中添加

Chain  

Signature 签名

export declare const Chain: chainable.Chain2<'ReaderTask'>

Added in v2.10.0 v2.10.0 中添加

FromIO   来自IO

Signature 签名

export declare const FromIO: FromIO2<'ReaderTask'>

Added in v2.10.0 v2.10.0 中添加

FromReader   来自读者

Signature 签名

export declare const FromReader: FromReader2<'ReaderTask'>

Added in v2.11.0 v2.11.0 中添加

FromTask   来自任务

Signature 签名

export declare const FromTask: FromTask2<'ReaderTask'>

Added in v2.10.0 v2.10.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor2<'ReaderTask'>

Added in v2.7.0 v2.7.0 中添加

Monad   单子

Signature 签名

export declare const Monad: Monad2<'ReaderTask'>

Added in v2.10.0 v2.10.0 中添加

MonadIO   莫纳德奥

Signature 签名

export declare const MonadIO: MonadIO2<'ReaderTask'>

Added in v2.10.0 v2.10.0 中添加

MonadTask  单子任务

Signature 签名

export declare const MonadTask: MonadTask2<'ReaderTask'>

Added in v2.10.0 v2.10.0 中添加

Pointed  

Signature 签名

export declare const Pointed: Pointed2<'ReaderTask'>

Added in v2.10.0 v2.10.0 中添加

legacy   遗产

chain  

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chain: <A, R, B>(f: (a: A) => ReaderTask<R, B>) => (ma: ReaderTask<R, A>) => ReaderTask<R, B>

Added in v2.3.0 v2.3.0中添加

chainFirst   链优先

Alias of tap.  tap 的别名。

Signature 签名

export declare const chainFirst: <A, R, B>(
  f: (a: A) => ReaderTask<R, B>
) => (first: ReaderTask<R, A>) => ReaderTask<R, A>

Added in v2.3.0 v2.3.0中添加

chainFirstIOK  链第一IOK

Alias of tapIO.  tapIO 的别名。

Signature 签名

export declare const chainFirstIOK: <A, B>(f: (a: A) => IO<B>) => <R>(first: ReaderTask<R, A>) => ReaderTask<R, A>

Added in v2.10.0 v2.10.0 中添加

chainFirstReaderIOK  chainFirstReaderIOK

Alias of tapReaderIO.  tapReaderIO 的别名。

Signature 签名

export declare const chainFirstReaderIOK: <A, R, B>(
  f: (a: A) => RIO.ReaderIO<R, B>
) => (ma: ReaderTask<R, A>) => ReaderTask<R, A>

Added in v2.13.0 v2.13.0 中添加

chainFirstReaderIOKW   chainFirstReaderIOKW

Alias of tapReaderIO.  tapReaderIO 的别名。

Less strict version of chainFirstReaderIOK.
chainFirstReaderIOK 的不太严格版本。

Signature 签名

export declare const chainFirstReaderIOKW: <A, R2, B>(
  f: (a: A) => RIO.ReaderIO<R2, B>
) => <R1>(ma: ReaderTask<R1, A>) => ReaderTask<R1 & R2, A>

Added in v2.13.0 v2.13.0 中添加

chainFirstReaderK  链第一读者K

Alias of tapReader.  tapReader 的别名。

Signature 签名

export declare const chainFirstReaderK: <A, R, B>(
  f: (a: A) => R.Reader<R, B>
) => (ma: ReaderTask<R, A>) => ReaderTask<R, A>

Added in v2.11.0 v2.11.0 中添加

chainFirstReaderKW  chainFirstReaderKW

Alias of tapReader.  tapReader 的别名。

Less strict version of chainFirstReaderK.
chainFirstReaderK 的不太严格版本。

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const chainFirstReaderKW: <A, R1, B>(
  f: (a: A) => R.Reader<R1, B>
) => <R2>(ma: ReaderTask<R2, A>) => ReaderTask<R1 & R2, A>

Added in v2.11.0 v2.11.0 中添加

chainFirstTaskK  链第一任务K

Alias of tapTask.  tapTask 的别名。

Signature 签名

export declare const chainFirstTaskK: <A, B>(f: (a: A) => T.Task<B>) => <R>(first: ReaderTask<R, A>) => ReaderTask<R, A>

Added in v2.10.0 v2.10.0 中添加

chainFirstW  链优先W

Alias of tap.  tap 的别名。

Signature 签名

export declare const chainFirstW: <R2, A, B>(
  f: (a: A) => ReaderTask<R2, B>
) => <R1>(ma: ReaderTask<R1, A>) => ReaderTask<R1 & R2, A>

Added in v2.11.0 v2.11.0 中添加

chainIOK  链IOK

Alias of flatMapIO.  flatMapIO 的别名。

Signature 签名

export declare const chainIOK: <A, B>(f: (a: A) => IO<B>) => <R>(first: ReaderTask<R, A>) => ReaderTask<R, B>

Added in v2.4.0 v2.4.0中添加

chainReaderIOK  链读器IOK

Alias of flatMapReaderIO.  flatMapReaderIO 的别名。

Signature 签名

export declare const chainReaderIOK: <A, R, B>(
  f: (a: A) => RIO.ReaderIO<R, B>
) => (ma: ReaderTask<R, A>) => ReaderTask<R, B>

Added in v2.13.0 v2.13.0 中添加

chainReaderIOKW   链读器IOKW

Alias of flatMapReaderIO.  flatMapReaderIO 的别名。

Less strict version of chainReaderIOK.
chainReaderIOK 的不太严格版本。

Signature 签名

export declare const chainReaderIOKW: <A, R2, B>(
  f: (a: A) => RIO.ReaderIO<R2, B>
) => <R1>(ma: ReaderTask<R1, A>) => ReaderTask<R1 & R2, B>

Added in v2.13.0 v2.13.0 中添加

chainReaderK  链读器K

Alias of flatMapReader.  flatMapReader 的别名。

Signature 签名

export declare const chainReaderK: <A, R, B>(f: (a: A) => R.Reader<R, B>) => (ma: ReaderTask<R, A>) => ReaderTask<R, B>

Added in v2.11.0 v2.11.0 中添加

chainReaderKW  链式阅读器KW

Alias of flatMapReader.  flatMapReader 的别名。

Less strict version of chainReaderK.
chainReaderK 的不太严格版本。

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const chainReaderKW: <A, R1, B>(
  f: (a: A) => R.Reader<R1, B>
) => <R2>(ma: ReaderTask<R2, A>) => ReaderTask<R1 & R2, B>

Added in v2.11.0 v2.11.0 中添加

chainTaskK  链任务K

Alias of flatMapTask.  flatMapTask 的别名。

Signature 签名

export declare const chainTaskK: <A, B>(f: (a: A) => T.Task<B>) => <R>(first: ReaderTask<R, A>) => ReaderTask<R, B>

Added in v2.4.0 v2.4.0中添加

chainW   链W

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chainW: <R2, A, B>(
  f: (a: A) => ReaderTask<R2, B>
) => <R1>(ma: ReaderTask<R1, A>) => ReaderTask<R1 & R2, B>

Added in v2.6.7 v2.6.7 中添加

lifting   起重

fromIOK   来自IOK

Signature 签名

export declare const fromIOK: <A extends readonly unknown[], B>(
  f: (...a: A) => IO<B>
) => <R = unknown>(...a: A) => ReaderTask<R, B>

Added in v2.4.0 v2.4.0中添加

fromReaderIOK   来自读者IOK

Signature 签名

export declare const fromReaderIOK: <A extends readonly unknown[], R, B>(
  f: (...a: A) => RIO.ReaderIO<R, B>
) => (...a: A) => ReaderTask<R, B>

Added in v2.13.0 v2.13.0 中添加

fromReaderK   来自ReaderK

Signature 签名

export declare const fromReaderK: <A extends readonly unknown[], R, B>(
  f: (...a: A) => R.Reader<R, B>
) => (...a: A) => ReaderTask<R, B>

Added in v2.11.0 v2.11.0 中添加

fromTaskK   来自任务K

Signature 签名

export declare const fromTaskK: <A extends readonly unknown[], B>(
  f: (...a: A) => T.Task<B>
) => <R = unknown>(...a: A) => ReaderTask<R, B>

Added in v2.4.0 v2.4.0中添加

mapping   映射

as   作为

Maps the value to the specified constant value.
将值映射到指定的常量值。

Signature 签名

export declare const as: {
  <A>(a: A): <R, _>(self: ReaderTask<R, _>) => ReaderTask<R, A>
  <R, _, A>(self: ReaderTask<R, _>, a: A): ReaderTask<R, A>
}

Added in v2.16.0 v2.16.0 中添加

asUnit   作为单位

Maps the value to the void constant value.
将值映射到 void 常量值。

Signature 签名

export declare const asUnit: <R, _>(self: ReaderTask<R, _>) => ReaderTask<R, void>

Added in v2.16.0 v2.16.0 中添加

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <E, B>(fab: ReaderTask<E, (a: A) => B>) => ReaderTask<E, B>

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => <R>(fa: ReaderTask<R, A>) => ReaderTask<R, B>

Added in v2.3.0 v2.3.0中添加

model   模型

ReaderTask (interface)   ReaderTask(接口)

Signature 签名

export interface ReaderTask<R, A> {
  (r: R): Task<A>
}

Added in v2.3.0 v2.3.0中添加

sequencing   测序

flatMap   平面地图

Signature 签名

export declare const flatMap: {
  <A, R2, B>(f: (a: A) => ReaderTask<R2, B>): <R1>(ma: ReaderTask<R1, A>) => ReaderTask<R1 & R2, B>
  <R1, A, R2, B>(ma: ReaderTask<R1, A>, f: (a: A) => ReaderTask<R2, B>): ReaderTask<R1 & R2, B>
}

Added in v2.14.0 v2.14.0 中添加

flatMapIO   平面MapIO

Signature 签名

export declare const flatMapIO: {
  <A, B>(f: (a: A) => IO<B>): <R>(self: ReaderTask<R, A>) => ReaderTask<R, B>
  <R, A, B>(self: ReaderTask<R, A>, f: (a: A) => IO<B>): ReaderTask<R, B>
}

Added in v2.16.0 v2.16.0 中添加

flatMapReader   平面地图阅读器

Signature 签名

export declare const flatMapReader: {
  <A, R2, B>(f: (a: A) => R.Reader<R2, B>): <R1>(self: ReaderTask<R1, A>) => ReaderTask<R1 & R2, B>
  <R1, A, R2, B>(self: ReaderTask<R1, A>, f: (a: A) => R.Reader<R2, B>): ReaderTask<R1 & R2, B>
}

Added in v2.16.0 v2.16.0 中添加

flatMapReaderIO   平面MapReaderIO

Signature 签名

export declare const flatMapReaderIO: {
  <A, R2, B>(f: (a: A) => RIO.ReaderIO<R2, B>): <R1>(self: ReaderTask<R1, A>) => ReaderTask<R1 & R2, B>
  <R1, A, R2, B>(self: ReaderTask<R1, A>, f: (a: A) => RIO.ReaderIO<R2, B>): ReaderTask<R1 & R2, B>
}

Added in v2.16.0 v2.16.0 中添加

flatMapTask  平面地图任务

Signature 签名

export declare const flatMapTask: {
  <A, B>(f: (a: A) => T.Task<B>): <R>(self: ReaderTask<R, A>) => ReaderTask<R, B>
  <R, A, B>(self: ReaderTask<R, A>, f: (a: A) => T.Task<B>): ReaderTask<R, B>
}

Added in v2.16.0 v2.16.0 中添加

flatten   压扁

Signature 签名

export declare const flatten: <R, A>(mma: ReaderTask<R, ReaderTask<R, A>>) => ReaderTask<R, A>

Added in v2.3.0 v2.3.0中添加

flattenW   展平W

Less strict version of flatten.
flatten 的不太严格版本。

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const flattenW: <R1, R2, A>(mma: ReaderTask<R1, ReaderTask<R2, A>>) => ReaderTask<R1 & R2, A>

Added in v2.11.0 v2.11.0 中添加

traversing   穿越

sequenceArray   序列数组

Equivalent to ReadonlyArray#sequence(Applicative). 相当于 ReadonlyArray#sequence(Applicative)

Signature 签名

export declare const sequenceArray: <R, A>(arr: readonly ReaderTask<R, A>[]) => ReaderTask<R, readonly A[]>

Added in v2.9.0 v2.9.0中添加

traverseArray   遍历数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseArray: <R, A, B>(
  f: (a: A) => ReaderTask<R, B>
) => (as: readonly A[]) => ReaderTask<R, readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseArrayWithIndex   带索引遍历数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseArrayWithIndex: <R, A, B>(
  f: (index: number, a: A) => ReaderTask<R, B>
) => (as: readonly A[]) => ReaderTask<R, readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseReadonlyArrayWithIndex
遍历带索引的只读数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseReadonlyArrayWithIndex: <A, R, B>(
  f: (index: number, a: A) => ReaderTask<R, B>
) => (as: readonly A[]) => ReaderTask<R, readonly B[]>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyArrayWithIndexSeq
遍历ReadonlyArrayWithIndexSeq

Equivalent to ReadonlyArray#traverseWithIndex(ApplicativeSeq). 相当于 ReadonlyArray#traverseWithIndex(ApplicativeSeq)

Signature 签名

export declare const traverseReadonlyArrayWithIndexSeq: <R, A, B>(
  f: (index: number, a: A) => ReaderTask<R, B>
) => (as: readonly A[]) => ReaderTask<R, readonly B[]>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyNonEmptyArrayWithIndex
遍历ReadonlyNonEmptyArrayWithIndex

Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(Applicative). 相当于 ReadonlyNonEmptyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseReadonlyNonEmptyArrayWithIndex: <A, R, B>(
  f: (index: number, a: A) => ReaderTask<R, B>
) => (as: ReadonlyNonEmptyArray<A>) => ReaderTask<R, ReadonlyNonEmptyArray<B>>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyNonEmptyArrayWithIndexSeq
遍历ReadonlyNonEmptyArrayWithIndexSeq

Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq). 相当于 ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq)

Signature 签名

export declare const traverseReadonlyNonEmptyArrayWithIndexSeq: <R, A, B>(
  f: (index: number, a: A) => ReaderTask<R, B>
) => (as: ReadonlyNonEmptyArray<A>) => ReaderTask<R, ReadonlyNonEmptyArray<B>>

Added in v2.11.0 v2.11.0 中添加

traverseSeqArray   遍历SeqArray

Equivalent to ReadonlyArray#traverse(ApplicativeSeq). 相当于 ReadonlyArray#traverse(ApplicativeSeq)

Signature 签名

export declare const traverseSeqArray: <R, A, B>(
  f: (a: A) => ReaderTask<R, B>
) => (as: readonly A[]) => ReaderTask<R, readonly B[]>

Added in v2.10.0 v2.10.0 中添加

traverseSeqArrayWithIndex
带索引的遍历SeqArray

Equivalent to ReadonlyArray#traverseWithIndex(ApplicativeSeq). 相当于 ReadonlyArray#traverseWithIndex(ApplicativeSeq)

Signature 签名

export declare const traverseSeqArrayWithIndex: <R, A, B>(
  f: (index: number, a: A) => ReaderTask<R, B>
) => (as: readonly A[]) => ReaderTask<R, readonly B[]>

Added in v2.10.0 v2.10.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'ReaderTask'

Added in v2.3.0 v2.3.0中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.3.0 v2.3.0中添加

utils   实用程序

ApT   易于

Signature 签名

export declare const ApT: ReaderTask<unknown, readonly []>

Added in v2.11.0 v2.11.0 中添加

ap   美联社

Signature 签名

export declare const ap: <R, A>(fa: ReaderTask<R, A>) => <B>(fab: ReaderTask<R, (a: A) => B>) => ReaderTask<R, B>

Added in v2.3.0 v2.3.0中添加

apFirst   应用程序第一

Combine two effectful actions, keeping only the result of the first.
结合两个有效的操作,仅保留第一个操作的结果。

Signature 签名

export declare const apFirst: <E, B>(second: ReaderTask<E, B>) => <A>(first: ReaderTask<E, A>) => ReaderTask<E, A>

Added in v2.3.0 v2.3.0中添加

apSecond   ap秒

Combine two effectful actions, keeping only the result of the second.
结合两个有效的操作,只保留第二个的结果。

Signature 签名

export declare const apSecond: <E, B>(second: ReaderTask<E, B>) => <A>(first: ReaderTask<E, A>) => ReaderTask<E, B>

Added in v2.3.0 v2.3.0中添加

apW   平均功率

Less strict version of ap.
ap 的不太严格版本。

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const apW: <R2, A>(
  fa: ReaderTask<R2, A>
) => <R1, B>(fab: ReaderTask<R1, (a: A) => B>) => ReaderTask<R1 & R2, B>

Added in v2.8.0 v2.8.0 中添加

local   当地的

Changes the value of the local context during the execution of the action ma (similar to Contravariant’s contramap).
在执行操作 ma 期间更改本地上下文的值(类似于 Contravariantcontramap )。

Signature 签名

export declare const local: <R2, R1>(f: (r2: R2) => R1) => <A>(ma: ReaderTask<R1, A>) => ReaderTask<R2, A>

Added in v2.3.0 v2.3.0中添加

zone of death
死亡地带

getMonoid 获取Monoid

Use getApplicativeMonoid instead. 请改用 getApplicativeMonoid

Signature 签名

export declare const getMonoid: <R, A>(M: Monoid<A>) => Monoid<ReaderTask<R, A>>

Added in v2.3.0 v2.3.0中添加

getSemigroup 获取半群

Use getApplySemigroup instead. 请改用 getApplySemigroup

Signature 签名

export declare const getSemigroup: <R, A>(S: Semigroup<A>) => Semigroup<ReaderTask<R, A>>

Added in v2.3.0 v2.3.0中添加

readerTaskSeq 读者任务序列

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass RT.Functor instead of RT.readerTaskSeq (where RT is from import RT from 'fp-ts/ReaderTask')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 RT.Functor 而不是 RT.readerTaskSeq (其中 RT 来自 import RT from 'fp-ts/ReaderTask'

Signature 签名

export declare const readerTaskSeq: MonadTask2<'ReaderTask'>

Added in v2.3.0 v2.3.0中添加

readerTask 读者任务

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass RT.Functor instead of RT.readerTask (where RT is from import RT from 'fp-ts/ReaderTask')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 RT.Functor 而不是 RT.readerTask (其中 RT 来自 import RT from 'fp-ts/ReaderTask'

Signature 签名

export declare const readerTask: MonadTask2<'ReaderTask'>

Added in v2.3.0 v2.3.0中添加

run 跑步

Signature 签名

export declare function run<R, A>(ma: ReaderTask<R, A>, r: R): Promise<A>

Added in v2.4.0 v2.4.0中添加

sequenceSeqArray 序列SeqArray

Use traverseReadonlyArrayWithIndexSeq instead. 请改用 traverseReadonlyArrayWithIndexSeq

Signature 签名

export declare const sequenceSeqArray: <R, A>(arr: readonly ReaderTask<R, A>[]) => ReaderTask<R, readonly A[]>

Added in v2.10.0 v2.10.0 中添加

ReaderTaskEither overview
ReaderTaskEither 概述

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


combinators   组合器

tap   轻敲

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tap: {
  <R1, E1, A, R2, E2, _>(self: ReaderTaskEither<R1, E1, A>, f: (a: A) => ReaderTaskEither<R2, E2, _>): ReaderTaskEither<
    R1 & R2,
    E1 | E2,
    A
  >
  <A, R2, E2, _>(f: (a: A) => ReaderTaskEither<R2, E2, _>): <R1, E1>(
    self: ReaderTaskEither<R1, E1, A>
  ) => ReaderTaskEither<R1 & R2, E2 | E1, A>
}

Added in v2.15.0 v2.15.0 中添加

tapEither   点击任一

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapEither: {
  <A, E2, _>(f: (a: A) => E.Either<E2, _>): <R, E1>(self: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2 | E1, A>
  <R, E1, A, E2, _>(self: ReaderTaskEither<R, E1, A>, f: (a: A) => E.Either<E2, _>): ReaderTaskEither<R, E1 | E2, A>
}

Example 例子

import * as E from 'fp-ts/Either'
import { pipe } from 'fp-ts/function'
import * as RTE from 'fp-ts/ReaderTaskEither'

const checkString = (value: string) =>
  pipe(
    RTE.ask<number>(),
    RTE.tapEither((minLength) => (value.length > minLength ? E.right('ok') : E.left('error')))
  )

async function test() {
  assert.deepStrictEqual(await checkString('')(2)(), E.left('error'))
  assert.deepStrictEqual(await checkString('fp-ts')(2)(), E.right(2))
}

test()

Added in v2.16.0 v2.16.0 中添加

tapIO   tapIO

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapIO: {
  <A, _>(f: (a: A) => IO<_>): <R, E>(self: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>
  <R, E, A, _>(self: ReaderTaskEither<R, E, A>, f: (a: A) => IO<_>): ReaderTaskEither<R, E, A>
}

Example 例子

import * as RTE from 'fp-ts/ReaderTaskEither'
import * as E from 'fp-ts/Either'
import * as Console from 'fp-ts/Console'

// Will produce `Hello, fp-ts` to the stdout
const effect = RTE.tapIO(RTE.ask<string>(), (value) => Console.log(`Hello, ${value}`))

async function test() {
  assert.deepStrictEqual(await effect('fp-ts')(), E.of('fp-ts'))
}

test()

Added in v2.16.0 v2.16.0 中添加

tapReader   点击阅读器

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapReader: {
  <A, R2, _>(f: (a: A) => R.Reader<R2, _>): <R1, E>(self: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R1 & R2, E, A>
  <R1, E, A, R2, _>(self: ReaderTaskEither<R1, E, A>, f: (a: A) => R.Reader<R2, _>): ReaderTaskEither<R1 & R2, E, A>
}

Added in v2.16.0 v2.16.0 中添加

tapReaderEither   TapReaderEither

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapReaderEither: {
  <A, R2, E2, _>(f: (a: A) => ReaderEither<R2, E2, _>): <R1, E1>(
    self: ReaderTaskEither<R1, E1, A>
  ) => ReaderTaskEither<R1 & R2, E2 | E1, A>
  <R1, E1, A, R2, E2, _>(self: ReaderTaskEither<R1, E1, A>, f: (a: A) => ReaderEither<R2, E2, _>): ReaderTaskEither<
    R1 & R2,
    E1 | E2,
    A
  >
}

Added in v2.16.0 v2.16.0 中添加

tapReaderIO   TapReaderIO

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapReaderIO: {
  <A, R2, _>(f: (a: A) => RT.ReaderTask<R2, _>): <R1, E>(
    self: ReaderTaskEither<R1, E, A>
  ) => ReaderTaskEither<R1 & R2, E, A>
  <R1, E, A, R2, _>(self: ReaderTaskEither<R1, E, A>, f: (a: A) => RIO.ReaderIO<R2, _>): ReaderTaskEither<R1 & R2, E, A>
}

Added in v2.16.0 v2.16.0 中添加

tapReaderTask   点击阅读器任务

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapReaderTask: {
  <A, R2, _>(f: (a: A) => RT.ReaderTask<R2, _>): <R1, E>(
    self: ReaderTaskEither<R1, E, A>
  ) => ReaderTaskEither<R1 & R2, E, A>
  <R1, E, A, R2, _>(self: ReaderTaskEither<R1, E, A>, f: (a: A) => RT.ReaderTask<R2, _>): ReaderTaskEither<
    R1 & R2,
    E,
    A
  >
}

Added in v2.16.0 v2.16.0 中添加

tapTask   点击任务

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapTask: {
  <A, _>(f: (a: A) => T.Task<_>): <R, E>(self: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>
  <R, E, A, _>(self: ReaderTaskEither<R, E, A>, f: (a: A) => T.Task<_>): ReaderTaskEither<R, E, A>
}

Example 例子

import * as RTE from 'fp-ts/ReaderTaskEither'
import * as E from 'fp-ts/Either'
import * as T from 'fp-ts/Task'

const effect = RTE.tapTask(RTE.ask<number>(), (value) => T.of(value + 1))

async function test() {
  assert.deepStrictEqual(await effect(1)(), E.of(1))
}

test()

Added in v2.16.0 v2.16.0 中添加

tapTaskEither  点击任务之一

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapTaskEither: {
  <A, E2, _>(f: (a: A) => TE.TaskEither<E2, _>): <R, E1>(
    self: ReaderTaskEither<R, E1, A>
  ) => ReaderTaskEither<R, E2 | E1, A>
  <R, E1, A, E2, _>(self: ReaderTaskEither<R, E1, A>, f: (a: A) => TE.TaskEither<E2, _>): ReaderTaskEither<
    R,
    E1 | E2,
    A
  >
}

Added in v2.16.0 v2.16.0 中添加

constructors  构造函数

ask  

Reads the current context.
读取当前上下文。

Signature 签名

export declare const ask: <R, E = never>() => ReaderTaskEither<R, E, R>

Added in v2.0.0 v2.0.0 中添加

asks  

Projects a value from the global context in a ReaderEither.
将全局上下文中的值投影到 ReaderEither 中。

Signature 签名

export declare const asks: <R, A, E = never>(f: (r: R) => A) => ReaderTaskEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

asksReaderTaskEither  询问读者任务

Effectfully accesses the environment.
有效地访问环境。

Signature 签名

export declare const asksReaderTaskEither: <R, E, A>(
  f: (r: R) => ReaderTaskEither<R, E, A>
) => ReaderTaskEither<R, E, A>

Added in v2.11.0 v2.11.0 中添加

asksReaderTaskEitherW   AskReaderTaskEitherW

Less strict version of asksReaderTaskEither.
asksReaderTaskEither 的不太严格版本。

The W suffix (short for Widening) means that the environment types will be merged.
W 后缀(Widening 的缩写)意味着环境类型将被合并。

Signature 签名

export declare const asksReaderTaskEitherW: <R1, R2, E, A>(
  f: (r1: R1) => ReaderTaskEither<R2, E, A>
) => ReaderTaskEither<R1 & R2, E, A>

Added in v2.11.0 v2.11.0 中添加

left  左边

Signature 签名

export declare const left: <R, E = never, A = never>(e: E) => ReaderTaskEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

leftIO   左IO

Signature 签名

export declare const leftIO: <R, E = never, A = never>(me: IO<E>) => ReaderTaskEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

leftReader   左读者

Signature 签名

export declare const leftReader: <R, E = never, A = never>(me: R.Reader<R, E>) => ReaderTaskEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

leftReaderIO   左读卡器IO

Signature 签名

export declare const leftReaderIO: <R, E = never, A = never>(me: RIO.ReaderIO<R, E>) => ReaderTaskEither<R, E, A>

Added in v2.13.0 v2.13.0 中添加

leftReaderTask   左读者任务

Signature 签名

export declare const leftReaderTask: <R, E = never, A = never>(me: RT.ReaderTask<R, E>) => ReaderTaskEither<R, E, A>

Added in v2.5.0 v2.5.0中添加

leftTask   左任务

Signature 签名

export declare const leftTask: <R, E = never, A = never>(me: T.Task<E>) => ReaderTaskEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

of  

Signature 签名

export declare const of: <R = unknown, E = never, A = never>(a: A) => ReaderTaskEither<R, E, A>

Added in v2.7.0 v2.7.0 中添加

Signature 签名

export declare const right: <R, E = never, A = never>(a: A) => ReaderTaskEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

rightIO   右IO

Signature 签名

export declare const rightIO: <R, E = never, A = never>(ma: IO<A>) => ReaderTaskEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

rightReader   右阅读器

Signature 签名

export declare const rightReader: <R, E = never, A = never>(ma: R.Reader<R, A>) => ReaderTaskEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

rightReaderIO   右读卡器IO

Signature 签名

export declare const rightReaderIO: <R, E = never, A = never>(ma: RIO.ReaderIO<R, A>) => ReaderTaskEither<R, E, A>

Added in v2.13.0 v2.13.0 中添加

rightReaderTask   右读者任务

Signature 签名

export declare const rightReaderTask: <R, E = never, A = never>(ma: RT.ReaderTask<R, A>) => ReaderTaskEither<R, E, A>

Added in v2.5.0 v2.5.0中添加

rightTask   正确的任务

Signature 签名

export declare const rightTask: <R, E = never, A = never>(ma: T.Task<A>) => ReaderTaskEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

conversions   转换

fromEither   来自任一

Signature 签名

export declare const fromEither: <E, A, R = unknown>(fa: E.Either<E, A>) => ReaderTaskEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

fromIO   来自IO

Signature 签名

export declare const fromIO: <A, R = unknown, E = never>(fa: IO<A>) => ReaderTaskEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

fromIOEither   来自IOEither

Signature 签名

export declare const fromIOEither: <E, A, R = unknown>(fa: IOEither<E, A>) => ReaderTaskEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

fromNullable   来自可为空的

Signature 签名

export declare const fromNullable: <E>(e: E) => <R, A>(a: A) => ReaderTaskEither<R, E, NonNullable<A>>

Added in v2.12.0 v2.12.0 中添加

fromOption   来自选项

Signature 签名

export declare const fromOption: <E>(onNone: LazyArg<E>) => <A, R = unknown>(fa: Option<A>) => ReaderTaskEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

fromReader   来自读者

Signature 签名

export declare const fromReader: <R, A, E = never>(fa: R.Reader<R, A>) => ReaderTaskEither<R, E, A>

Added in v2.11.0 v2.11.0 中添加

fromReaderEither   来自读者要么

Signature 签名

export declare const fromReaderEither: <R, E, A>(fa: ReaderEither<R, E, A>) => ReaderTaskEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

fromTask   来自任务

Signature 签名

export declare const fromTask: <A, R = unknown, E = never>(fa: T.Task<A>) => ReaderTaskEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

fromTaskEither   来自任务要么

Signature 签名

export declare const fromTaskEither: <E, A, R = unknown>(fa: TE.TaskEither<E, A>) => ReaderTaskEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

toUnion   至联盟

Signature 签名

export declare const toUnion: <R, E, A>(fa: ReaderTaskEither<R, E, A>) => RT.ReaderTask<R, E | A>

Added in v2.10.0 v2.10.0 中添加

do notation   做记号

Do  

Signature 签名

export declare const Do: ReaderTaskEither<unknown, never, {}>

Added in v2.9.0 v2.9.0中添加

apS   apS

Signature 签名

export declare const apS: <N, A, R, E, B>(
  name: Exclude<N, keyof A>,
  fb: ReaderTaskEither<R, E, B>
) => (
  fa: ReaderTaskEither<R, E, A>
) => ReaderTaskEither<R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

apSW   apSW

Less strict version of apS.
apS 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const apSW: <A, N extends string, R2, E2, B>(
  name: Exclude<N, keyof A>,
  fb: ReaderTaskEither<R2, E2, B>
) => <R1, E1>(
  fa: ReaderTaskEither<R1, E1, A>
) => ReaderTaskEither<R1 & R2, E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bind   绑定

Signature 签名

export declare const bind: <N, A, R, E, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => ReaderTaskEither<R, E, B>
) => (
  ma: ReaderTaskEither<R, E, A>
) => ReaderTaskEither<R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bindTo   绑定到

Signature 签名

export declare const bindTo: <N>(
  name: N
) => <R, E, A>(fa: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, { readonly [K in N]: A }>

Added in v2.8.0 v2.8.0 中添加

bindW   绑定W

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const bindW: <N extends string, A, R2, E2, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => ReaderTaskEither<R2, E2, B>
) => <R1, E1>(
  fa: ReaderTaskEither<R1, E1, A>
) => ReaderTaskEither<R1 & R2, E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

let  

Signature 签名

export declare const let: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => <R, E>(
  fa: ReaderTaskEither<R, E, A>
) => ReaderTaskEither<R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.13.0 v2.13.0 中添加

error handling   错误处理

alt   替代

Identifies an associative operation on a type constructor. It is similar to Semigroup, except that it applies to types of kind * -> *.
标识类型构造函数上的关联操作。它与 Semigroup 类似,但它适用于 * -> * 类型。

Signature 签名

export declare const alt: <R, E, A>(
  that: () => ReaderTaskEither<R, E, A>
) => (fa: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

altW   替代W

Less strict version of alt.
alt 的不太严格版本。

The W suffix (short for Widening) means that the environment, the error and the return types will be merged.
W 后缀(Widening 的缩写)意味着环境、错误和返回类型将被合并。

Signature 签名

export declare const altW: <R2, E2, B>(
  that: () => ReaderTaskEither<R2, E2, B>
) => <R1, E1, A>(fa: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E2, B | A>

Added in v2.9.0 v2.9.0中添加

getAltReaderTaskValidation
获取AltReaderTaskValidation

The default Alt instance returns the last error, if you want to get all errors you need to provide a way to concatenate them via a Semigroup.
默认的 Alt 实例返回最后一个错误,如果你想获取所有错误,你需要提供一种通过 Semigroup 连接它们的方法。

See getAltValidation. 请参阅 getAltValidation

Signature 签名

export declare function getAltReaderTaskValidation<E>(S: Semigroup<E>): Alt3C<URI, E>

Added in v2.7.0 v2.7.0 中添加

getApplicativeReaderTaskValidation
获取ApplicativeReaderTaskValidation

The default ApplicativePar instance returns the first error, if you want to get all errors you need to provide a way to concatenate them via a Semigroup.
默认的 ApplicativePar 实例返回第一个错误,如果您想获取所有错误,您需要提供一种通过 Semigroup 连接它们的方法。

See getApplicativeValidation. 请参阅 getApplicativeValidation

Signature 签名

export declare function getApplicativeReaderTaskValidation<E>(A: Apply1<T.URI>, S: Semigroup<E>): Applicative3C<URI, E>

Added in v2.7.0 v2.7.0 中添加

getOrElse  获取或否则

Signature 签名

export declare const getOrElse: <R, E, A>(
  onLeft: (e: E) => RT.ReaderTask<R, A>
) => (ma: ReaderTaskEither<R, E, A>) => RT.ReaderTask<R, A>

Added in v2.0.0 v2.0.0 中添加

getOrElseW   获取或否则W

Less strict version of getOrElse.
getOrElse 的不太严格版本。

The W suffix (short for Widening) means that the handler return type will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const getOrElseW: <R2, E, B>(
  onLeft: (e: E) => RT.ReaderTask<R2, B>
) => <R1, A>(ma: ReaderTaskEither<R1, E, A>) => RT.ReaderTask<R1 & R2, B | A>

Added in v2.6.0 v2.6.0 中添加

mapBoth   地图两者

Returns a ReaderTaskEither whose failure and success channels have been mapped by the specified pair of functions, f and g.
返回一个 ReaderTaskEither ,其失败和成功通道已由指定的函数对 fg 映射。

Signature 签名

export declare const mapBoth: {
  <E, G, A, B>(f: (e: E) => G, g: (a: A) => B): <R>(self: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, G, B>
  <R, E, A, G, B>(self: ReaderTaskEither<R, E, A>, f: (e: E) => G, g: (a: A) => B): ReaderTaskEither<R, G, B>
}

Example 例子

import * as ReaderTaskEither from 'fp-ts/ReaderTaskEither'
import * as Either from 'fp-ts/Either'

const f = (s: string) => new Error(s)
const g = (n: number) => n * 2

async function test() {
  assert.deepStrictEqual(await ReaderTaskEither.mapBoth(ReaderTaskEither.right(1), f, g)({})(), Either.right(2))
  assert.deepStrictEqual(
    await ReaderTaskEither.mapBoth(ReaderTaskEither.left('err'), f, g)({})(),
    Either.left(new Error('err'))
  )
}

test()

Added in v2.16.0 v2.16.0 中添加

mapError   地图错误

Returns a ReaderTaskEither with its error channel mapped using the specified function.
返回 ReaderTaskEither 及其使用指定函数映射的错误通道。

Signature 签名

export declare const mapError: {
  <R, E, G>(f: (e: E) => G): <A>(self: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, G, A>
  <R, E, A, G>(self: ReaderTaskEither<R, E, A>, f: (e: E) => G): ReaderTaskEither<R, G, A>
}

Example 例子

import * as ReaderTaskEither from 'fp-ts/ReaderTaskEither'
import * as Either from 'fp-ts/Either'

const f = (s: string) => new Error(s)

async function test() {
  assert.deepStrictEqual(await ReaderTaskEither.mapError(ReaderTaskEither.right(1), f)({})(), Either.right(1))
  assert.deepStrictEqual(
    await ReaderTaskEither.mapError(ReaderTaskEither.left('err'), f)({})(),
    Either.left(new Error('err'))
  )
}

test()

Added in v2.16.0 v2.16.0 中添加

orElse   要不然

Signature 签名

export declare const orElse: <R, E1, A, E2>(
  onLeft: (e: E1) => ReaderTaskEither<R, E2, A>
) => (ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2, A>

Added in v2.0.0 v2.0.0 中添加

orElseW   否则W

Less strict version of orElse.
orElse 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the return types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和返回类型将被合并。

Signature 签名

export declare const orElseW: <E1, R1, E2, B>(
  onLeft: (e: E1) => ReaderTaskEither<R1, E2, B>
) => <R2, A>(ma: ReaderTaskEither<R2, E1, A>) => ReaderTaskEither<R1 & R2, E2, B | A>

Added in v2.10.0 v2.10.0 中添加

orLeft   或向左

Signature 签名

export declare const orLeft: <E1, R, E2>(
  onLeft: (e: E1) => RT.ReaderTask<R, E2>
) => <A>(fa: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2, A>

Added in v2.11.0 v2.11.0 中添加

tapError   点击错误

Returns an effect that effectfully “peeks” at the failure of this effect.
返回一个效果,有效地“窥视”此效果的失败。

Signature 签名

export declare const tapError: {
  <E1, R2, E2, _>(onLeft: (e: E1) => ReaderTaskEither<R2, E2, _>): <R1, A>(
    self: ReaderTaskEither<R1, E1, A>
  ) => ReaderTaskEither<R1 & R2, E1 | E2, A>
  <R1, E1, A, R2, E2, _>(
    self: ReaderTaskEither<R1, E1, A>,
    onLeft: (e: E1) => ReaderTaskEither<R2, E2, _>
  ): ReaderTaskEither<R1 & R2, E1 | E2, A>
}

Added in v2.15.0 v2.15.0 中添加

filtering   过滤

filterOrElse  过滤器或者其他

Signature 签名

export declare const filterOrElse: {
  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(
    ma: ReaderTaskEither<R, E, A>
  ) => ReaderTaskEither<R, E, B>
  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R, B extends A>(
    mb: ReaderTaskEither<R, E, B>
  ) => ReaderTaskEither<R, E, B>
  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>
}

Added in v2.0.0 v2.0.0 中添加

filterOrElseW   过滤器否则W

Less strict version of filterOrElse.
filterOrElse 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const filterOrElseW: {
  <A, B extends A, E2>(refinement: Refinement<A, B>, onFalse: (a: A) => E2): <R, E1>(
    ma: ReaderTaskEither<R, E1, A>
  ) => ReaderTaskEither<R, E2 | E1, B>
  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <R, E1, B extends A>(
    mb: ReaderTaskEither<R, E1, B>
  ) => ReaderTaskEither<R, E2 | E1, B>
  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <R, E1>(
    ma: ReaderTaskEither<R, E1, A>
  ) => ReaderTaskEither<R, E2 | E1, A>
}

Added in v2.9.0 v2.9.0中添加

getCompactable   获取可压缩的

Signature 签名

export declare const getCompactable: <E>(M: Monoid<E>) => Compactable3C<'ReaderTaskEither', E>

Added in v2.10.0 v2.10.0 中添加

getFilterable   获取可过滤的

Signature 签名

export declare function getFilterable<E>(M: Monoid<E>): Filterable3C<URI, E>

Added in v2.10.0 v2.10.0 中添加

instances   实例

Alt   替代

Signature 签名

export declare const Alt: Alt3<'ReaderTaskEither'>

Added in v2.7.0 v2.7.0 中添加

ApplicativePar   应用性参数

Runs computations in parallel.
并行运行计算。

Signature 签名

export declare const ApplicativePar: Applicative3<'ReaderTaskEither'>

Added in v2.7.0 v2.7.0 中添加

ApplicativeSeq   应用序列

Runs computations sequentially.
按顺序运行计算。

Signature 签名

export declare const ApplicativeSeq: Applicative3<'ReaderTaskEither'>

Added in v2.7.0 v2.7.0 中添加

ApplyPar   申请帕

Runs computations in parallel.
并行运行计算。

Signature 签名

export declare const ApplyPar: Apply3<'ReaderTaskEither'>

Added in v2.10.0 v2.10.0 中添加

ApplySeq   应用序列

Runs computations sequentially.
按顺序运行计算。

Signature 签名

export declare const ApplySeq: Apply3<'ReaderTaskEither'>

Added in v2.10.0 v2.10.0 中添加

Bifunctor   双函子

Signature 签名

export declare const Bifunctor: Bifunctor3<'ReaderTaskEither'>

Added in v2.7.0 v2.7.0 中添加

Chain  

Signature 签名

export declare const Chain: chainable.Chain3<'ReaderTaskEither'>

Added in v2.10.0 v2.10.0 中添加

FromEither   来自任一

Signature 签名

export declare const FromEither: FromEither3<'ReaderTaskEither'>

Added in v2.10.0 v2.10.0 中添加

FromIO   来自IO

Signature 签名

export declare const FromIO: FromIO3<'ReaderTaskEither'>

Added in v2.10.0 v2.10.0 中添加

FromReader   来自读者

Signature 签名

export declare const FromReader: FromReader3<'ReaderTaskEither'>

Added in v2.11.0 v2.11.0 中添加

FromTask   来自任务

Signature 签名

export declare const FromTask: FromTask3<'ReaderTaskEither'>

Added in v2.10.0 v2.10.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor3<'ReaderTaskEither'>

Added in v2.7.0 v2.7.0 中添加

Monad   单子

Signature 签名

export declare const Monad: Monad3<'ReaderTaskEither'>

Added in v2.10.0 v2.10.0 中添加

MonadIO   莫纳德奥

Signature 签名

export declare const MonadIO: MonadIO3<'ReaderTaskEither'>

Added in v2.10.0 v2.10.0 中添加

MonadTask  单子任务

Signature 签名

export declare const MonadTask: MonadTask3<'ReaderTaskEither'>

Added in v2.10.0 v2.10.0 中添加

MonadThrow   单子投掷

Signature 签名

export declare const MonadThrow: MonadThrow3<'ReaderTaskEither'>

Added in v2.10.0 v2.10.0 中添加

Pointed  

Signature 签名

export declare const Pointed: Pointed3<'ReaderTaskEither'>

Added in v2.10.0 v2.10.0 中添加

getReaderTaskValidation 获取ReaderTaskValidation

Use getApplicativeReaderTaskValidation and getAltReaderTaskValidation instead.
请改用 getApplicativeReaderTaskValidationgetAltReaderTaskValidation

Signature 签名

export declare function getReaderTaskValidation<E>(
  SE: Semigroup<E>
): Monad3C<URI, E> & Bifunctor3<URI> & Alt3C<URI, E> & MonadTask3C<URI, E> & MonadThrow3C<URI, E>

Added in v2.3.0 v2.3.0中添加

legacy   遗产

bimap   双图

Alias of mapBoth.  mapBoth 的别名。

Signature 签名

export declare const bimap: <E, G, A, B>(
  f: (e: E) => G,
  g: (a: A) => B
) => <R>(fa: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, G, B>

Added in v2.0.0 v2.0.0 中添加

chain  

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chain: <R, E, A, B>(
  f: (a: A) => ReaderTaskEither<R, E, B>
) => (ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>

Added in v2.0.0 v2.0.0 中添加

chainEitherK  链EiK

Alias of flatMapEither.  flatMapEither 的别名。

Signature 签名

export declare const chainEitherK: <E, A, B>(
  f: (a: A) => E.Either<E, B>
) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>

Added in v2.4.0 v2.4.0中添加

chainEitherKW  链条任一KW

Alias of flatMapEither.  flatMapEither 的别名。

Signature 签名

export declare const chainEitherKW: <E2, A, B>(
  f: (a: A) => E.Either<E2, B>
) => <R, E1>(ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2 | E1, B>

Added in v2.6.1 v2.6.1 中添加

chainFirst   链优先

Alias of tap.  tap 的别名。

Signature 签名

export declare const chainFirst: <R, E, A, B>(
  f: (a: A) => ReaderTaskEither<R, E, B>
) => (ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

chainFirstEitherK  链FirstEiK

Alias of tapEither.  tapEither 的别名。

Signature 签名

export declare const chainFirstEitherK: <A, E, B>(
  f: (a: A) => E.Either<E, B>
) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>

Added in v2.12.0 v2.12.0 中添加

chainFirstEitherKW   链FirstEiKW

Alias of tapEither.  tapEither 的别名。

Less strict version of chainFirstEitherK.
chainFirstEitherK 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const chainFirstEitherKW: <A, E2, B>(
  f: (a: A) => E.Either<E2, B>
) => <R, E1>(ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2 | E1, A>

Added in v2.12.0 v2.12.0 中添加

chainFirstIOK  链第一IOK

Alias of tapIO.  tapIO 的别名。

Signature 签名

export declare const chainFirstIOK: <A, B>(
  f: (a: A) => IO<B>
) => <R, E>(first: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>

Added in v2.10.0 v2.10.0 中添加

chainFirstReaderEitherK
chainFirstReaderEitherK

Alias of tapReaderEither.  tapReaderEither 的别名。

Signature 签名

export declare const chainFirstReaderEitherK: <R, E, A, B>(
  f: (a: A) => ReaderEither<R, E, B>
) => (ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>

Added in v2.11.0 v2.11.0 中添加

chainFirstReaderEitherKW
chainFirstReaderEitherKW

Alias of tapReaderEither.  tapReaderEither 的别名。

Less strict version of chainFirstReaderEitherK.
chainFirstReaderEitherK 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const chainFirstReaderEitherKW: <R2, E2, A, B>(
  f: (a: A) => ReaderEither<R2, E2, B>
) => <R1, E1>(ma: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E2 | E1, A>

Added in v2.11.0 v2.11.0 中添加

chainFirstReaderIOK  chainFirstReaderIOK

Alias of tapReaderIO.  tapReaderIO 的别名。

Signature 签名

export declare const chainFirstReaderIOK: <A, R, B>(
  f: (a: A) => RIO.ReaderIO<R, B>
) => <E>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>

Added in v2.13.0 v2.13.0 中添加

chainFirstReaderIOKW   chainFirstReaderIOKW

Alias of tapReaderIO.  tapReaderIO 的别名。

Less strict version of chainFirstReaderIOK.
chainFirstReaderIOK 的不太严格版本。

Signature 签名

export declare const chainFirstReaderIOKW: <A, R2, B>(
  f: (a: A) => RIO.ReaderIO<R2, B>
) => <R1, E>(ma: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R1 & R2, E, A>

Added in v2.13.0 v2.13.0 中添加

chainFirstReaderK  链第一读者K

Alias of tapReader.  tapReader 的别名。

Signature 签名

export declare const chainFirstReaderK: <A, R, B>(
  f: (a: A) => R.Reader<R, B>
) => <E>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>

Added in v2.11.0 v2.11.0 中添加

chainFirstReaderKW  chainFirstReaderKW

Alias of tapReader.  tapReader 的别名。

Less strict version of chainFirstReaderK.
chainFirstReaderK 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const chainFirstReaderKW: <A, R1, B>(
  f: (a: A) => R.Reader<R1, B>
) => <R2, E>(ma: ReaderTaskEither<R2, E, A>) => ReaderTaskEither<R1 & R2, E, A>

Added in v2.11.0 v2.11.0 中添加

chainFirstReaderTaskK   chainFirstReaderTaskK

Alias of tapReaderTask.  tapReaderTask 的别名。

Signature 签名

export declare const chainFirstReaderTaskK: <A, R, B>(
  f: (a: A) => RT.ReaderTask<R, B>
) => <E>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>

Added in v2.11.0 v2.11.0 中添加

chainFirstReaderTaskKW   chainFirstReaderTaskKW

Alias of tapReaderTask.  tapReaderTask 的别名。

Less strict version of chainFirstReaderTaskK.
chainFirstReaderTaskK 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const chainFirstReaderTaskKW: <A, R2, B>(
  f: (a: A) => RT.ReaderTask<R2, B>
) => <R1, E>(ma: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R1 & R2, E, A>

Added in v2.11.0 v2.11.0 中添加

chainFirstTaskEitherK  chainFirstTaskEitherK

Alias of tapTaskEither.  tapTaskEither 的别名。

Signature 签名

export declare const chainFirstTaskEitherK: <E, A, B>(
  f: (a: A) => TE.TaskEither<E, B>
) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>

Added in v2.11.0 v2.11.0 中添加

chainFirstTaskEitherKW   chainFirstTaskEitherKW

Alias of tapTaskEither.  tapTaskEither 的别名。

Less strict version of chainFirstTaskEitherK.
chainFirstTaskEitherK 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const chainFirstTaskEitherKW: <E2, A, B>(
  f: (a: A) => TE.TaskEither<E2, B>
) => <R, E1>(ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2 | E1, A>

Added in v2.11.0 v2.11.0 中添加

chainFirstTaskK  链第一任务K

Alias of tapTask.  tapTask 的别名。

Signature 签名

export declare const chainFirstTaskK: <A, B>(
  f: (a: A) => T.Task<B>
) => <R, E>(first: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>

Added in v2.10.0 v2.10.0 中添加

chainFirstW  链优先W

Alias of tap.  tap 的别名。

Signature 签名

export declare const chainFirstW: <R2, E2, A, B>(
  f: (a: A) => ReaderTaskEither<R2, E2, B>
) => <R1, E1>(ma: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E2 | E1, A>

Added in v2.8.0 v2.8.0 中添加

chainIOEitherK  链IOEitherK

Alias of flatMapIOEither.  flatMapIOEither 的别名。

Signature 签名

export declare const chainIOEitherK: <E, A, B>(
  f: (a: A) => IOEither<E, B>
) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>

Added in v2.4.0 v2.4.0中添加

chainIOEitherKW   链IOEitherKW

Alias of flatMapIOEither.  flatMapIOEither 的别名。

Less strict version of chainIOEitherK.
chainIOEitherK 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const chainIOEitherKW: <E2, A, B>(
  f: (a: A) => IOEither<E2, B>
) => <R, E1>(ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2 | E1, B>

Added in v2.6.1 v2.6.1 中添加

chainIOK  链IOK

Alias of flatMapIO.  flatMapIO 的别名。

Signature 签名

export declare const chainIOK: <A, B>(
  f: (a: A) => IO<B>
) => <R, E>(first: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>

Added in v2.10.0 v2.10.0 中添加

chainNullableK   链可空K

Use flatMapNullable. 使用 flatMapNullable

Signature 签名

export declare const chainNullableK: <E>(
  e: E
) => <A, B>(
  f: (a: A) => B | null | undefined
) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, NonNullable<B>>

Added in v2.12.0 v2.12.0 中添加

chainOptionK   链选项K

Use flatMapOption. 使用 flatMapOption

Signature 签名

export declare const chainOptionK: <E>(
  onNone: LazyArg<E>
) => <A, B>(f: (a: A) => Option<B>) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>

Added in v2.10.0 v2.10.0 中添加

chainOptionKW   链条选项KW

Use flatMapOption. 使用 flatMapOption

Signature 签名

export declare const chainOptionKW: <E2>(
  onNone: LazyArg<E2>
) => <A, B>(f: (a: A) => Option<B>) => <R, E1>(ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2 | E1, B>

Added in v2.13.2 v2.13.2 中添加

chainReaderEitherK   chainReaderEitherK

Alias of flatMapReaderEither.  flatMapReaderEither 的别名。

Signature 签名

export declare const chainReaderEitherK: <R, E, A, B>(
  f: (a: A) => ReaderEither<R, E, B>
) => (ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>

Added in v2.11.0 v2.11.0 中添加

chainReaderEitherKW   链读器EitherKW

Alias of flatMapReaderEither.  flatMapReaderEither 的别名。

Less strict version of chainReaderEitherK.
chainReaderEitherK 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const chainReaderEitherKW: <R2, E2, A, B>(
  f: (a: A) => ReaderEither<R2, E2, B>
) => <R1, E1>(ma: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E2 | E1, B>

Added in v2.11.0 v2.11.0 中添加

chainReaderIOK  链读器IOK

Alias of flatMapReaderIO.  flatMapReaderIO 的别名。

Signature 签名

export declare const chainReaderIOK: <A, R, B>(
  f: (a: A) => RIO.ReaderIO<R, B>
) => <E>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>

Added in v2.13.0 v2.13.0 中添加

chainReaderIOKW   链读器IOKW

Alias of flatMapReaderIO.  flatMapReaderIO 的别名。

Less strict version of chainReaderIOK.
chainReaderIOK 的不太严格版本。

Signature 签名

export declare const chainReaderIOKW: <A, R2, B>(
  f: (a: A) => RIO.ReaderIO<R2, B>
) => <R1, E>(ma: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R1 & R2, E, B>

Added in v2.13.0 v2.13.0 中添加

chainReaderK  链读器K

Alias of flatMapReader.  flatMapReader 的别名。

Signature 签名

export declare const chainReaderK: <A, R, B>(
  f: (a: A) => R.Reader<R, B>
) => <E>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>

Added in v2.11.0 v2.11.0 中添加

chainReaderKW  链式阅读器KW

Alias of flatMapReader.  flatMapReader 的别名。

Less strict version of chainReaderK.
chainReaderK 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const chainReaderKW: <A, R1, B>(
  f: (a: A) => R.Reader<R1, B>
) => <R2, E>(ma: ReaderTaskEither<R2, E, A>) => ReaderTaskEither<R1 & R2, E, B>

Added in v2.11.0 v2.11.0 中添加

chainReaderTaskK   chainReaderTaskK

Alias of flatMapReaderTask.  flatMapReaderTask 的别名。

Signature 签名

export declare const chainReaderTaskK: <A, R, B>(
  f: (a: A) => RT.ReaderTask<R, B>
) => <E>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>

Added in v2.11.0 v2.11.0 中添加

chainReaderTaskKW   chainReaderTaskKW

Alias of flatMapReaderTask.  flatMapReaderTask 的别名。

Less strict version of chainReaderTaskK.
chainReaderTaskK 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const chainReaderTaskKW: <A, R2, B>(
  f: (a: A) => RT.ReaderTask<R2, B>
) => <R1, E>(ma: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R1 & R2, E, B>

Added in v2.11.0 v2.11.0 中添加

chainTaskEitherK   chainTaskEitherK

Alias of flatMapTaskEither.  flatMapTaskEither 的别名。

Signature 签名

export declare const chainTaskEitherK: <E, A, B>(
  f: (a: A) => TE.TaskEither<E, B>
) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>

Added in v2.4.0 v2.4.0中添加

chainTaskEitherKW   chainTaskEitherKW

Alias of flatMapTaskEither.  flatMapTaskEither 的别名。

Less strict version of chainTaskEitherK.
chainTaskEitherK 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const chainTaskEitherKW: <E2, A, B>(
  f: (a: A) => TE.TaskEither<E2, B>
) => <R, E1>(ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2 | E1, B>

Added in v2.6.1 v2.6.1 中添加

chainTaskK  链任务K

Alias of flatMapTask.  flatMapTask 的别名。

Signature 签名

export declare const chainTaskK: <A, B>(
  f: (a: A) => T.Task<B>
) => <R, E>(first: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>

Added in v2.10.0 v2.10.0 中添加

chainW   链W

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chainW: <R2, E2, A, B>(
  f: (a: A) => ReaderTaskEither<R2, E2, B>
) => <R1, E1>(ma: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E2 | E1, B>

Added in v2.6.0 v2.6.0 中添加

fromNullableK  来自可空K

Use liftNullable. 使用 liftNullable

Signature 签名

export declare const fromNullableK: <E>(
  e: E
) => <A extends readonly unknown[], B>(
  f: (...a: A) => B | null | undefined
) => <R = unknown>(...a: A) => ReaderTaskEither<R, E, NonNullable<B>>

Added in v2.12.0 v2.12.0 中添加

fromOptionK   来自选项K

Use liftOption. 使用 liftOption

Signature 签名

export declare const fromOptionK: <E>(
  onNone: LazyArg<E>
) => <A extends readonly unknown[], B>(f: (...a: A) => Option<B>) => <R = unknown>(...a: A) => ReaderTaskEither<R, E, B>

Added in v2.10.0 v2.10.0 中添加

mapLeft   地图左

Alias of mapError.  mapError 的别名。

Signature 签名

export declare const mapLeft: <E, G>(
  f: (e: E) => G
) => <R, A>(fa: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, G, A>

Added in v2.0.0 v2.0.0 中添加

orElseFirst   或其他优先

Alias of tapError.  tapError 的别名。

Signature 签名

export declare const orElseFirst: <E, R, B>(
  onLeft: (e: E) => ReaderTaskEither<R, E, B>
) => <A>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>

Added in v2.11.0 v2.11.0 中添加

orElseFirstW   否则先W

Alias of tapError.  tapError 的别名。

Signature 签名

export declare const orElseFirstW: <E1, R2, E2, B>(
  onLeft: (e: E1) => ReaderTaskEither<R2, E2, B>
) => <R1, A>(ma: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E1 | E2, A>

Added in v2.11.0 v2.11.0 中添加

lifting   起重

fromEitherK   来自EitherK

Signature 签名

export declare const fromEitherK: <E, A extends readonly unknown[], B>(
  f: (...a: A) => E.Either<E, B>
) => <R = unknown>(...a: A) => ReaderTaskEither<R, E, B>

Added in v2.4.0 v2.4.0中添加

fromIOEitherK   来自IOEitherK

Signature 签名

export declare const fromIOEitherK: <E, A extends readonly unknown[], B>(
  f: (...a: A) => IOEither<E, B>
) => <R = unknown>(...a: A) => ReaderTaskEither<R, E, B>

Added in v2.4.0 v2.4.0中添加

fromIOK   来自IOK

Signature 签名

export declare const fromIOK: <A extends readonly unknown[], B>(
  f: (...a: A) => IO<B>
) => <R = unknown, E = never>(...a: A) => ReaderTaskEither<R, E, B>

Added in v2.10.0 v2.10.0 中添加

fromPredicate   来自谓词

Signature 签名

export declare const fromPredicate: {
  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R = unknown>(
    a: A
  ) => ReaderTaskEither<R, E, B>
  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R = unknown, B extends A = A>(
    b: B
  ) => ReaderTaskEither<R, E, B>
  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R = unknown>(a: A) => ReaderTaskEither<R, E, A>
}

Added in v2.0.0 v2.0.0 中添加

fromReaderEitherK   来自读者EitherK

Signature 签名

export declare const fromReaderEitherK: <R, E, A extends readonly unknown[], B>(
  f: (...a: A) => ReaderEither<R, E, B>
) => (...a: A) => ReaderTaskEither<R, E, B>

Added in v2.11.0 v2.11.0 中添加

fromReaderIOK   来自读者IOK

Signature 签名

export declare const fromReaderIOK: <A extends readonly unknown[], R, B>(
  f: (...a: A) => RIO.ReaderIO<R, B>
) => <E = never>(...a: A) => ReaderTaskEither<R, E, B>

Added in v2.13.0 v2.13.0 中添加

fromReaderK   来自ReaderK

Signature 签名

export declare const fromReaderK: <A extends readonly unknown[], R, B>(
  f: (...a: A) => R.Reader<R, B>
) => <E = never>(...a: A) => ReaderTaskEither<R, E, B>

Added in v2.11.0 v2.11.0 中添加

fromReaderTaskK   来自ReaderTaskK

Signature 签名

export declare const fromReaderTaskK: <A extends readonly unknown[], R, B>(
  f: (...a: A) => RT.ReaderTask<R, B>
) => <E = never>(...a: A) => ReaderTaskEither<R, E, B>

Added in v2.11.0 v2.11.0 中添加

fromTaskEitherK  来自TaskEitherK

Signature 签名

export declare const fromTaskEitherK: <E, A extends readonly unknown[], B>(
  f: (...a: A) => TE.TaskEither<E, B>
) => <R = unknown>(...a: A) => ReaderTaskEither<R, E, B>

Added in v2.4.0 v2.4.0中添加

fromTaskK   来自任务K

Signature 签名

export declare const fromTaskK: <A extends readonly unknown[], B>(
  f: (...a: A) => T.Task<B>
) => <R = unknown, E = never>(...a: A) => ReaderTaskEither<R, E, B>

Added in v2.10.0 v2.10.0 中添加

liftNullable   提升可为空

Signature 签名

export declare const liftNullable: <A extends readonly unknown[], B, E>(
  f: (...a: A) => B | null | undefined,
  onNullable: (...a: A) => E
) => <R>(...a: A) => ReaderTaskEither<R, E, NonNullable<B>>

Added in v2.15.0 v2.15.0 中添加

liftOption   电梯选项

Signature 签名

export declare const liftOption: <A extends readonly unknown[], B, E>(
  f: (...a: A) => Option<B>,
  onNone: (...a: A) => E
) => <R>(...a: A) => ReaderTaskEither<R, E, B>

Added in v2.15.0 v2.15.0 中添加

mapping   映射

as   作为

Maps the Right value of this ReaderTaskEither to the specified constant value.
将此 ReaderTaskEitherRight 值映射到指定的常量值。

Signature 签名

export declare const as: {
  <A>(a: A): <R, E, _>(self: ReaderTaskEither<R, E, _>) => ReaderTaskEither<R, E, A>
  <R, E, _, A>(self: ReaderTaskEither<R, E, _>, a: A): ReaderTaskEither<R, E, A>
}

Added in v2.16.0 v2.16.0 中添加

asUnit   作为单位

Maps the Right value of this ReaderTaskEither to the void constant value.
将此 ReaderTaskEitherRight 值映射到void 常量值。

Signature 签名

export declare const asUnit: <R, E, _>(self: ReaderTaskEither<R, E, _>) => ReaderTaskEither<R, E, void>

Added in v2.16.0 v2.16.0 中添加

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <R, E, B>(fab: ReaderTaskEither<R, E, (a: A) => B>) => ReaderTaskEither<R, E, B>

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => <R, E>(fa: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>

Added in v2.0.0 v2.0.0 中添加

model   模型

ReaderTaskEither (interface)
ReaderTaskEither(接口)

Signature 签名

export interface ReaderTaskEither<R, E, A> {
  (r: R): TaskEither<E, A>
}

Added in v2.0.0 v2.0.0 中添加

pattern matching   模式匹配

fold   折叠

Alias of matchE.  matchE 的别名。

Signature 签名

export declare const fold: <R, E, A, B>(
  onLeft: (e: E) => RT.ReaderTask<R, B>,
  onRight: (a: A) => RT.ReaderTask<R, B>
) => (ma: ReaderTaskEither<R, E, A>) => RT.ReaderTask<R, B>

Added in v2.0.0 v2.0.0 中添加

foldW   折叠W

Alias of matchEW.  matchEW 的别名。

Signature 签名

export declare const foldW: <E, R2, B, A, R3, C>(
  onLeft: (e: E) => RT.ReaderTask<R2, B>,
  onRight: (a: A) => RT.ReaderTask<R3, C>
) => <R1>(ma: ReaderTaskEither<R1, E, A>) => RT.ReaderTask<R1 & R2 & R3, B | C>

Added in v2.10.0 v2.10.0 中添加

match   匹配

Signature 签名

export declare const match: <E, B, A>(
  onLeft: (e: E) => B,
  onRight: (a: A) => B
) => <R>(ma: ReaderTaskEither<R, E, A>) => RT.ReaderTask<R, B>

Added in v2.10.0 v2.10.0 中添加

matchE   匹配E

The E suffix (short for Effect) means that the handlers return an effect (ReaderTask).
E 后缀(Effect 的缩写)意味着处理程序返回一个效果 ( ReaderTask )。

Signature 签名

export declare const matchE: <R, E, A, B>(
  onLeft: (e: E) => RT.ReaderTask<R, B>,
  onRight: (a: A) => RT.ReaderTask<R, B>
) => (ma: ReaderTaskEither<R, E, A>) => RT.ReaderTask<R, B>

Added in v2.10.0 v2.10.0 中添加

matchEW   匹配电子战

Less strict version of matchE.
matchE 的不太严格版本。

The W suffix (short for Widening) means that the handler return types will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const matchEW: <E, R2, B, A, R3, C>(
  onLeft: (e: E) => RT.ReaderTask<R2, B>,
  onRight: (a: A) => RT.ReaderTask<R3, C>
) => <R1>(ma: ReaderTaskEither<R1, E, A>) => RT.ReaderTask<R1 & R2 & R3, B | C>

Added in v2.10.0 v2.10.0 中添加

matchW   匹配W

Less strict version of match.
match 的不太严格版本。

The W suffix (short for Widening) means that the handler return types will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const matchW: <E, B, A, C>(
  onLeft: (e: E) => B,
  onRight: (a: A) => C
) => <R>(ma: ReaderTaskEither<R, E, A>) => RT.ReaderTask<R, B | C>

Added in v2.10.0 v2.10.0 中添加

sequencing   测序

flatMap   平面地图

Signature 签名

export declare const flatMap: {
  <A, R2, E2, B>(f: (a: A) => ReaderTaskEither<R2, E2, B>): <R1, E1>(
    ma: ReaderTaskEither<R1, E1, A>
  ) => ReaderTaskEither<R1 & R2, E2 | E1, B>
  <R1, E1, A, R2, E2, B>(ma: ReaderTaskEither<R1, E1, A>, f: (a: A) => ReaderTaskEither<R2, E2, B>): ReaderTaskEither<
    R1 & R2,
    E1 | E2,
    B
  >
}

Added in v2.14.0 v2.14.0 中添加

flatMapEither   平面地图要么

Signature 签名

export declare const flatMapEither: {
  <A, E2, B>(f: (a: A) => E.Either<E2, B>): <R, E1>(self: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2 | E1, B>
  <R, E1, A, E2, B>(self: ReaderTaskEither<R, E1, A>, f: (a: A) => E.Either<E2, B>): ReaderTaskEither<R, E1 | E2, B>
}

Added in v2.15.0 v2.15.0 中添加

flatMapIO   平面MapIO

Signature 签名

export declare const flatMapIO: {
  <A, B>(f: (a: A) => IO<B>): <R, E>(self: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>
  <R, E, A, B>(self: ReaderTaskEither<R, E, A>, f: (a: A) => IO<B>): ReaderTaskEither<R, E, B>
}

Added in v2.16.0 v2.16.0 中添加

flatMapIOEither   平面MapIO要么

Signature 签名

export declare const flatMapIOEither: {
  <A, E2, B>(f: (a: A) => IOEither<E2, B>): <R, E1>(self: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2 | E1, B>
  <R, E1, A, E2, B>(self: ReaderTaskEither<R, E1, A>, f: (a: A) => IOEither<E2, B>): ReaderTaskEither<R, E1 | E2, B>
}

Added in v2.16.0 v2.16.0 中添加

flatMapNullable   平面地图可空

Signature 签名

export declare const flatMapNullable: {
  <A, B, E2>(f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): <R, E1>(
    self: ReaderTaskEither<R, E1, A>
  ) => ReaderTaskEither<R, E2 | E1, NonNullable<B>>
  <R, E1, A, B, E2>(
    self: ReaderTaskEither<R, E1, A>,
    f: (a: A) => B | null | undefined,
    onNullable: (a: A) => E2
  ): ReaderTaskEither<R, E1 | E2, NonNullable<B>>
}

Added in v2.15.0 v2.15.0 中添加

flatMapOption   平面地图选项

Signature 签名

export declare const flatMapOption: {
  <A, B, E2>(f: (a: A) => Option<B>, onNone: (a: A) => E2): <R, E1>(
    self: ReaderTaskEither<R, E1, A>
  ) => ReaderTaskEither<R, E2 | E1, B>
  <R, E1, A, B, E2>(self: ReaderTaskEither<R, E1, A>, f: (a: A) => Option<B>, onNone: (a: A) => E2): ReaderTaskEither<
    R,
    E1 | E2,
    B
  >
}

Added in v2.15.0 v2.15.0 中添加

flatMapReader   平面地图阅读器

Signature 签名

export declare const flatMapReader: {
  <A, R2, B>(f: (a: A) => R.Reader<R2, B>): <R1, E>(self: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R1 & R2, E, B>
  <R1, E, A, R2, B>(self: ReaderTaskEither<R1, E, A>, f: (a: A) => R.Reader<R2, B>): ReaderTaskEither<R1 & R2, E, B>
}

Added in v2.16.0 v2.16.0 中添加

flatMapReaderEither   平面地图阅读器要么

Signature 签名

export declare const flatMapReaderEither: {
  <A, R2, E2, B>(f: (a: A) => ReaderEither<R2, E2, B>): <R1, E1>(
    self: ReaderTaskEither<R1, E1, A>
  ) => ReaderTaskEither<R1 & R2, E2 | E1, B>
  <R1, E1, A, R2, E2, B>(self: ReaderTaskEither<R1, E1, A>, f: (a: A) => ReaderEither<R2, E2, B>): ReaderTaskEither<
    R1 & R2,
    E1 | E2,
    B
  >
}

Added in v2.16.0 v2.16.0 中添加

flatMapReaderIO   平面MapReaderIO

Signature 签名

export declare const flatMapReaderIO: {
  <A, R2, B>(f: (a: A) => RIO.ReaderIO<R2, B>): <R1, E>(
    self: ReaderTaskEither<R1, E, A>
  ) => ReaderTaskEither<R1 & R2, E, B>
  <R1, E, A, R2, B>(self: ReaderTaskEither<R1, E, A>, f: (a: A) => RIO.ReaderIO<R2, B>): ReaderTaskEither<R1 & R2, E, B>
}

Added in v2.16.0 v2.16.0 中添加

flatMapReaderTask  平面MapReader任务

Signature 签名

export declare const flatMapReaderTask: {
  <A, R2, B>(f: (a: A) => RT.ReaderTask<R2, B>): <R1, E>(
    self: ReaderTaskEither<R1, E, A>
  ) => ReaderTaskEither<R1 & R2, E, B>
  <R1, E, A, R2, B>(self: ReaderTaskEither<R1, E, A>, f: (a: A) => RT.ReaderTask<R2, B>): ReaderTaskEither<
    R1 & R2,
    E,
    B
  >
}

Added in v2.16.0 v2.16.0 中添加

flatMapTask  平面地图任务

Signature 签名

export declare const flatMapTask: {
  <A, B>(f: (a: A) => T.Task<B>): <R, E>(self: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>
  <R, E, A, B>(self: ReaderTaskEither<R, E, A>, f: (a: A) => T.Task<B>): ReaderTaskEither<R, E, B>
}

Added in v2.16.0 v2.16.0 中添加

flatMapTaskEither  flatMapTaskEither

Signature 签名

export declare const flatMapTaskEither: {
  <A, E2, B>(f: (a: A) => TE.TaskEither<E2, B>): <R, E1>(
    self: ReaderTaskEither<R, E1, A>
  ) => ReaderTaskEither<R, E2 | E1, B>
  <R, E1, A, E2, B>(self: ReaderTaskEither<R, E1, A>, f: (a: A) => TE.TaskEither<E2, B>): ReaderTaskEither<
    R,
    E1 | E2,
    B
  >
}

Added in v2.16.0 v2.16.0 中添加

flatten   压扁

Signature 签名

export declare const flatten: <R, E, A>(
  mma: ReaderTaskEither<R, E, ReaderTaskEither<R, E, A>>
) => ReaderTaskEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

flattenW   展平W

Less strict version of flatten.
flatten 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const flattenW: <R1, E1, R2, E2, A>(
  mma: ReaderTaskEither<R1, E1, ReaderTaskEither<R2, E2, A>>
) => ReaderTaskEither<R1 & R2, E1 | E2, A>

Added in v2.11.0 v2.11.0 中添加

traversing   穿越

sequenceArray   序列数组

Equivalent to ReadonlyArray#sequence(Applicative). 相当于 ReadonlyArray#sequence(Applicative)

Signature 签名

export declare const sequenceArray: <R, E, A>(
  arr: readonly ReaderTaskEither<R, E, A>[]
) => ReaderTaskEither<R, E, readonly A[]>

Added in v2.9.0 v2.9.0中添加

sequenceSeqArray   序列SeqArray

Equivalent to ReadonlyArray#sequence(ApplicativeSeq). 相当于 ReadonlyArray#sequence(ApplicativeSeq)

Signature 签名

export declare const sequenceSeqArray: <R, E, A>(
  arr: readonly ReaderTaskEither<R, E, A>[]
) => ReaderTaskEither<R, E, readonly A[]>

Added in v2.9.0 v2.9.0中添加

traverseArray   遍历数组

Equivalent to ReadonlyArray#traverse(Applicative). 相当于 ReadonlyArray#traverse(Applicative)

Signature 签名

export declare const traverseArray: <R, E, A, B>(
  f: (a: A) => ReaderTaskEither<R, E, B>
) => (as: readonly A[]) => ReaderTaskEither<R, E, readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseArrayWithIndex   带索引遍历数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseArrayWithIndex: <R, E, A, B>(
  f: (index: number, a: A) => ReaderTaskEither<R, E, B>
) => (as: readonly A[]) => ReaderTaskEither<R, E, readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseReadonlyArrayWithIndex
遍历带索引的只读数组

Equivalent to ReadonlyArray#traverseWithIndex(ApplicativePar). 相当于 ReadonlyArray#traverseWithIndex(ApplicativePar)

Signature 签名

export declare const traverseReadonlyArrayWithIndex: <A, R, E, B>(
  f: (index: number, a: A) => ReaderTaskEither<R, E, B>
) => (as: readonly A[]) => ReaderTaskEither<R, E, readonly B[]>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyArrayWithIndexSeq
遍历ReadonlyArrayWithIndexSeq

Equivalent to ReadonlyArray#traverseWithIndex(ApplicativeSeq). 相当于 ReadonlyArray#traverseWithIndex(ApplicativeSeq)

Signature 签名

export declare const traverseReadonlyArrayWithIndexSeq: <A, R, E, B>(
  f: (index: number, a: A) => ReaderTaskEither<R, E, B>
) => (as: readonly A[]) => ReaderTaskEither<R, E, readonly B[]>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyNonEmptyArrayWithIndex
遍历ReadonlyNonEmptyArrayWithIndex

Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar). 相当于 ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar)

Signature 签名

export declare const traverseReadonlyNonEmptyArrayWithIndex: <A, R, E, B>(
  f: (index: number, a: A) => ReaderTaskEither<R, E, B>
) => (as: ReadonlyNonEmptyArray<A>) => ReaderTaskEither<R, E, ReadonlyNonEmptyArray<B>>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyNonEmptyArrayWithIndexSeq
遍历ReadonlyNonEmptyArrayWithIndexSeq

Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq). 相当于 ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq)

Signature 签名

export declare const traverseReadonlyNonEmptyArrayWithIndexSeq: <A, R, E, B>(
  f: (index: number, a: A) => ReaderTaskEither<R, E, B>
) => (as: ReadonlyNonEmptyArray<A>) => ReaderTaskEither<R, E, ReadonlyNonEmptyArray<B>>

Added in v2.11.0 v2.11.0 中添加

traverseSeqArray   遍历SeqArray

Equivalent to ReadonlyArray#traverse(ApplicativeSeq). 相当于 ReadonlyArray#traverse(ApplicativeSeq)

Signature 签名

export declare const traverseSeqArray: <R, E, A, B>(
  f: (a: A) => ReaderTaskEither<R, E, B>
) => (as: readonly A[]) => ReaderTaskEither<R, E, readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseSeqArrayWithIndex
带索引的遍历SeqArray

Equivalent to ReadonlyArray#traverseWithIndex(ApplicativeSeq). 相当于 ReadonlyArray#traverseWithIndex(ApplicativeSeq)

Signature 签名

export declare const traverseSeqArrayWithIndex: <R, E, A, B>(
  f: (index: number, a: A) => ReaderTaskEither<R, E, B>
) => (as: readonly A[]) => ReaderTaskEither<R, E, readonly B[]>

Added in v2.9.0 v2.9.0中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'ReaderTaskEither'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

ApT   易于

Signature 签名

export declare const ApT: ReaderTaskEither<unknown, never, readonly []>

Added in v2.11.0 v2.11.0 中添加

ap   美联社

Signature 签名

export declare const ap: <R, E, A>(
  fa: ReaderTaskEither<R, E, A>
) => <B>(fab: ReaderTaskEither<R, E, (a: A) => B>) => ReaderTaskEither<R, E, B>

Added in v2.0.0 v2.0.0 中添加

apFirst   应用程序第一

Combine two effectful actions, keeping only the result of the first.
结合两个有效的操作,仅保留第一个操作的结果。

Signature 签名

export declare const apFirst: <R, E, B>(
  second: ReaderTaskEither<R, E, B>
) => <A>(first: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

apFirstW   apFirstW

Less strict version of apFirst.
apFirst 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const apFirstW: <R2, E2, B>(
  second: ReaderTaskEither<R2, E2, B>
) => <R1, E1, A>(first: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E2 | E1, A>

Added in v2.12.0 v2.12.0 中添加

apSecond   ap秒

Combine two effectful actions, keeping only the result of the second.
结合两个有效的操作,只保留第二个的结果。

Signature 签名

export declare const apSecond: <R, E, B>(
  second: ReaderTaskEither<R, E, B>
) => <A>(first: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>

Added in v2.0.0 v2.0.0 中添加

apSecondW   apSecondW

Less strict version of apSecond.
apSecond 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const apSecondW: <R2, E2, B>(
  second: ReaderTaskEither<R2, E2, B>
) => <R1, E1, A>(first: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E2 | E1, B>

Added in v2.12.0 v2.12.0 中添加

apW   平均功率

Less strict version of ap.
ap 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const apW: <R2, E2, A>(
  fa: ReaderTaskEither<R2, E2, A>
) => <R1, E1, B>(fab: ReaderTaskEither<R1, E1, (a: A) => B>) => ReaderTaskEither<R1 & R2, E2 | E1, B>

Added in v2.8.0 v2.8.0 中添加

bracket   括号

Make sure that a resource is cleaned up in the event of an exception (*). The release action is called regardless of whether the body action throws (*) or returns.
确保在发生异常时清理资源 (*)。无论主体操作是抛出 (*) 还是返回,都会调用释放操作。

(*) i.e. returns a Left
(*) 即返回 Left

Signature 签名

export declare function bracket<R, E, A, B>(
  acquire: ReaderTaskEither<R, E, A>,
  use: (a: A) => ReaderTaskEither<R, E, B>,
  release: (a: A, e: Either<E, B>) => ReaderTaskEither<R, E, void>
): ReaderTaskEither<R, E, B>

Added in v2.0.4 v2.0.4中添加

bracketW   支架W

Less strict version of bracket.
bracket 的不太严格版本。

Signature 签名

export declare function bracketW<R1, E1, A, R2, E2, B, R3, E3>(
  acquire: ReaderTaskEither<R1, E1, A>,
  use: (a: A) => ReaderTaskEither<R2, E2, B>,
  release: (a: A, e: Either<E2, B>) => ReaderTaskEither<R3, E3, void>
): ReaderTaskEither<R1 & R2 & R3, E1 | E2 | E3, B>

Added in v2.12.0 v2.12.0 中添加

local   当地的

Changes the value of the local context during the execution of the action ma (similar to Contravariant’s contramap).
在执行操作 ma 期间更改本地上下文的值(类似于 Contravariantcontramap )。

Signature 签名

export declare const local: <R2, R1>(
  f: (r2: R2) => R1
) => <E, A>(ma: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R2, E, A>

Added in v2.0.0 v2.0.0 中添加

swap   交换

Signature 签名

export declare const swap: <R, E, A>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, A, E>

Added in v2.0.0 v2.0.0 中添加

throwError   抛出错误

Signature 签名

export declare const throwError: <R, E, A>(e: E) => ReaderTaskEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

zone of death
死亡地带

getApplyMonoid 获取应用Monoid

Use getApplicativeMonoid instead. 请改用 getApplicativeMonoid

Signature 签名

export declare const getApplyMonoid: <R, E, A>(M: Monoid<A>) => Monoid<ReaderTaskEither<R, E, A>>

Added in v2.0.0 v2.0.0 中添加

getApplySemigroup 获取ApplySemigroup

Use getApplySemigroup instead. 请改用 getApplySemigroup

Semigroup returning the left-most Left value. If both operands are Rights then the inner values are concatenated using the provided Semigroup
半群返回最左边的 Left 值。如果两个操作数都是 Right s,则使用提供的 Semigroup 连接内部值

Signature 签名

export declare const getApplySemigroup: <R, E, A>(S: Semigroup<A>) => Semigroup<ReaderTaskEither<R, E, A>>

Added in v2.0.0 v2.0.0 中添加

getSemigroup 获取半群

Use getApplySemigroup instead. 请改用 getApplySemigroup

Signature 签名

export declare const getSemigroup: <R, E, A>(S: Semigroup<A>) => Semigroup<ReaderTaskEither<R, E, A>>

Added in v2.0.0 v2.0.0 中添加

readerTaskEitherSeq readerTaskEitherSeq

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass RTE.Functor instead of RTE.readerTaskEitherSeq (where RTE is from import RTE from 'fp-ts/ReaderTaskEither')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 RTE.Functor 而不是 RTE.readerTaskEitherSeq (其中 RTE 来自 import RTE from 'fp-ts/ReaderTaskEither'

Signature 签名

export declare const readerTaskEitherSeq: Monad3<'ReaderTaskEither'> &
  Bifunctor3<'ReaderTaskEither'> &
  Alt3<'ReaderTaskEither'> &
  MonadTask3<'ReaderTaskEither'> &
  MonadThrow3<'ReaderTaskEither'>

Added in v2.0.0 v2.0.0 中添加

readerTaskEither 读者任务要么

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass RTE.Functor instead of RTE.readerTaskEither (where RTE is from import RTE from 'fp-ts/ReaderTaskEither')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 RTE.Functor 而不是 RTE.readerTaskEither (其中 RTE 来自 import RTE from 'fp-ts/ReaderTaskEither'

Signature 签名

export declare const readerTaskEither: Monad3<'ReaderTaskEither'> &
  Bifunctor3<'ReaderTaskEither'> &
  Alt3<'ReaderTaskEither'> &
  MonadTask3<'ReaderTaskEither'> &
  MonadThrow3<'ReaderTaskEither'>

Added in v2.0.0 v2.0.0 中添加

run 跑步

Signature 签名

export declare function run<R, E, A>(ma: ReaderTaskEither<R, E, A>, r: R): Promise<Either<E, A>>

Added in v2.0.0 v2.0.0 中添加

ReadonlyArray overview  ReadonlyArray 概述

Added in v2.5.0 v2.5.0中添加


Table of contents
目录


constructors  构造函数

makeBy  制造者

Return a ReadonlyArray of length n with element i initialized with f(i).
返回长度为 nReadonlyArray ,其中元素 if(i) 初始化。

Note. n is normalized to a non negative integer.
笔记。 n 被标准化为非负整数。

Signature 签名

export declare const makeBy: <A>(n: number, f: (i: number) => A) => readonly A[]

Example 例子

import { makeBy } from 'fp-ts/ReadonlyArray'

const double = (n: number): number => n * 2
assert.deepStrictEqual(makeBy(5, double), [0, 2, 4, 6, 8])

Added in v2.5.0 v2.5.0中添加

of  

Signature 签名

export declare const of: <A>(a: A) => readonly A[]

Added in v2.5.0 v2.5.0中添加

replicate   复制

Create a ReadonlyArray containing a value repeated the specified number of times.
创建一个包含重复指定次数的值的 ReadonlyArray

Note. n is normalized to a non negative integer.
笔记。 n 被标准化为非负整数。

Signature 签名

export declare const replicate: <A>(n: number, a: A) => readonly A[]

Example 例子

import { replicate } from 'fp-ts/ReadonlyArray'

assert.deepStrictEqual(replicate(3, 'a'), ['a', 'a', 'a'])

Added in v2.5.0 v2.5.0中添加

conversions   转换

fromArray   来自数组

Signature 签名

export declare const fromArray: <A>(as: A[]) => readonly A[]

Added in v2.5.0 v2.5.0中添加

fromEither   来自任一

Transforms an Either to a ReadonlyArray.
Either 转换为 ReadonlyArray

Signature 签名

export declare const fromEither: <A>(fa: Either<unknown, A>) => readonly A[]

Added in v2.11.0 v2.11.0 中添加

fromOption   来自选项

Signature 签名

export declare const fromOption: <A>(fa: Option<A>) => readonly A[]

Added in v2.11.0 v2.11.0 中添加

toArray   到数组

Signature 签名

export declare const toArray: <A>(as: readonly A[]) => A[]

Added in v2.5.0 v2.5.0中添加

do notation   做记号

Do  

Signature 签名

export declare const Do: readonly {}[]

Added in v2.9.0 v2.9.0中添加

apS   apS

Signature 签名

export declare const apS: <N, A, B>(
  name: Exclude<N, keyof A>,
  fb: readonly B[]
) => (fa: readonly A[]) => readonly { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }[]

Added in v2.8.0 v2.8.0 中添加

bind   绑定

Signature 签名

export declare const bind: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => readonly B[]
) => (ma: readonly A[]) => readonly { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }[]

Added in v2.8.0 v2.8.0 中添加

bindTo   绑定到

Signature 签名

export declare const bindTo: <N>(name: N) => <A>(fa: readonly A[]) => readonly { readonly [K in N]: A }[]

Added in v2.8.0 v2.8.0 中添加

guard   警卫

Signature 签名

export declare const guard: (b: boolean) => readonly void[]

Added in v2.11.0 v2.11.0 中添加

let  

Signature 签名

export declare const let: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => (fa: readonly A[]) => readonly { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }[]

Added in v2.13.0 v2.13.0 中添加

error handling   错误处理

alt   替代

Identifies an associative operation on a type constructor. It is similar to Semigroup, except that it applies to types of kind * -> *.
标识类型构造函数上的关联操作。它与 Semigroup 类似,但它适用于 * -> * 类型。

In case of ReadonlyArray concatenates the inputs into a single array.
如果是 ReadonlyArray ,则将输入连接到单个数组中。

Signature 签名

export declare const alt: <A>(that: LazyArg<readonly A[]>) => (fa: readonly A[]) => readonly A[]

Example 例子

import * as RA from 'fp-ts/ReadonlyArray'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(
  pipe(
    [1, 2, 3],
    RA.alt(() => [4, 5])
  ),
  [1, 2, 3, 4, 5]
)

Added in v2.5.0 v2.5.0中添加

altW   替代W

Less strict version of alt.
alt 的不太严格版本。

The W suffix (short for Widening) means that the return types will be merged.
W 后缀(Widening 的缩写)意味着返回类型将被合并。

Signature 签名

export declare const altW: <B>(that: LazyArg<readonly B[]>) => <A>(fa: readonly A[]) => readonly (B | A)[]

Example 例子

import * as RA from 'fp-ts/ReadonlyArray'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(
  pipe(
    [1, 2, 3],
    RA.altW(() => ['a', 'b'])
  ),
  [1, 2, 3, 'a', 'b']
)

Added in v2.9.0 v2.9.0中添加

filtering   过滤

compact   袖珍的

Signature 签名

export declare const compact: <A>(fa: readonly Option<A>[]) => readonly A[]

Added in v2.5.0 v2.5.0中添加

filter   筛选

Signature 签名

export declare const filter: {
  <A, B extends A>(refinement: Refinement<A, B>): (as: readonly A[]) => readonly B[]
  <A>(predicate: Predicate<A>): <B extends A>(bs: readonly B[]) => readonly B[]
  <A>(predicate: Predicate<A>): (as: readonly A[]) => readonly A[]
}

Added in v2.5.0 v2.5.0中添加

filterMap   过滤映射

Signature 签名

export declare const filterMap: <A, B>(f: (a: A) => Option<B>) => (fa: readonly A[]) => readonly B[]

Added in v2.5.0 v2.5.0中添加

filterMapWithIndex   带索引的过滤映射

Signature 签名

export declare const filterMapWithIndex: <A, B>(f: (i: number, a: A) => Option<B>) => (fa: readonly A[]) => readonly B[]

Added in v2.5.0 v2.5.0中添加

filterWithIndex   带索引的过滤器

Signature 签名

export declare const filterWithIndex: {
  <A, B extends A>(refinementWithIndex: RefinementWithIndex<number, A, B>): (as: readonly A[]) => readonly B[]
  <A>(predicateWithIndex: PredicateWithIndex<number, A>): <B extends A>(bs: readonly B[]) => readonly B[]
  <A>(predicateWithIndex: PredicateWithIndex<number, A>): (as: readonly A[]) => readonly A[]
}

Added in v2.5.0 v2.5.0中添加

partition   分割

Signature 签名

export declare const partition: {
  <A, B extends A>(refinement: Refinement<A, B>): (as: readonly A[]) => Separated<readonly A[], readonly B[]>
  <A>(predicate: Predicate<A>): <B extends A>(bs: readonly B[]) => Separated<readonly B[], readonly B[]>
  <A>(predicate: Predicate<A>): (as: readonly A[]) => Separated<readonly A[], readonly A[]>
}

Added in v2.5.0 v2.5.0中添加

partitionMap   分区图

Signature 签名

export declare const partitionMap: <A, B, C>(
  f: (a: A) => Either<B, C>
) => (fa: readonly A[]) => Separated<readonly B[], readonly C[]>

Added in v2.5.0 v2.5.0中添加

partitionMapWithIndex   带索引的分区映射

Signature 签名

export declare const partitionMapWithIndex: <A, B, C>(
  f: (i: number, a: A) => Either<B, C>
) => (fa: readonly A[]) => Separated<readonly B[], readonly C[]>

Added in v2.5.0 v2.5.0中添加

partitionWithIndex   带索引分区

Signature 签名

export declare const partitionWithIndex: {
  <A, B extends A>(refinementWithIndex: RefinementWithIndex<number, A, B>): (
    as: readonly A[]
  ) => Separated<readonly A[], readonly B[]>
  <A>(predicateWithIndex: PredicateWithIndex<number, A>): <B extends A>(
    bs: readonly B[]
  ) => Separated<readonly B[], readonly B[]>
  <A>(predicateWithIndex: PredicateWithIndex<number, A>): (as: readonly A[]) => Separated<readonly A[], readonly A[]>
}

Added in v2.5.0 v2.5.0中添加

separate   分离

Signature 签名

export declare const separate: <A, B>(fa: readonly Either<A, B>[]) => Separated<readonly A[], readonly B[]>

Added in v2.5.0 v2.5.0中添加

wilt   枯萎

Signature 签名

export declare const wilt: PipeableWilt1<'ReadonlyArray'>

Added in v2.6.5 v2.6.5 中添加

wither   枯萎

Signature 签名

export declare const wither: PipeableWither1<'ReadonlyArray'>

Added in v2.6.5 v2.6.5 中添加

folding   折叠式的

foldMap   折叠图

Signature 签名

export declare const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: readonly A[]) => M

Added in v2.5.0 v2.5.0中添加

foldMapWithIndex   带索引的折叠地图

Signature 签名

export declare const foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: number, a: A) => M) => (fa: readonly A[]) => M

Added in v2.5.0 v2.5.0中添加

reduce   减少

Signature 签名

export declare const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: readonly A[]) => B

Added in v2.5.0 v2.5.0中添加

reduceRight   减少右

Signature 签名

export declare const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: readonly A[]) => B

Added in v2.5.0 v2.5.0中添加

reduceRightWithIndex   减少右索引

Signature 签名

export declare const reduceRightWithIndex: <A, B>(b: B, f: (i: number, a: A, b: B) => B) => (fa: readonly A[]) => B

Added in v2.5.0 v2.5.0中添加

reduceWithIndex  减少索引

Signature 签名

export declare const reduceWithIndex: <A, B>(b: B, f: (i: number, b: B, a: A) => B) => (fa: readonly A[]) => B

Added in v2.5.0 v2.5.0中添加

instances   实例

Alt   替代

Signature 签名

export declare const Alt: Alt1<'ReadonlyArray'>

Added in v2.7.0 v2.7.0 中添加

Alternative   选择

Signature 签名

export declare const Alternative: Alternative1<'ReadonlyArray'>

Added in v2.7.0 v2.7.0 中添加

Applicative   适用性

Signature 签名

export declare const Applicative: Applicative1<'ReadonlyArray'>

Added in v2.7.0 v2.7.0 中添加

Apply   申请

Signature 签名

export declare const Apply: Apply1<'ReadonlyArray'>

Added in v2.10.0 v2.10.0 中添加

Chain  

Signature 签名

export declare const Chain: Chain1<'ReadonlyArray'>

Added in v2.10.0 v2.10.0 中添加

ChainRecBreadthFirst   链式记录宽度优先

Signature 签名

export declare const ChainRecBreadthFirst: ChainRec1<'ReadonlyArray'>

Added in v2.11.0 v2.11.0 中添加

ChainRecDepthFirst   链式记录深度优先

Signature 签名

export declare const ChainRecDepthFirst: ChainRec1<'ReadonlyArray'>

Added in v2.11.0 v2.11.0 中添加

Compactable   紧凑型

Signature 签名

export declare const Compactable: Compactable1<'ReadonlyArray'>

Added in v2.7.0 v2.7.0 中添加

Extend   延长

Signature 签名

export declare const Extend: Extend1<'ReadonlyArray'>

Added in v2.7.0 v2.7.0 中添加

Filterable   可过滤

Signature 签名

export declare const Filterable: Filterable1<'ReadonlyArray'>

Added in v2.7.0 v2.7.0 中添加

FilterableWithIndex   可通过索引过滤

Signature 签名

export declare const FilterableWithIndex: FilterableWithIndex1<'ReadonlyArray', number>

Added in v2.7.0 v2.7.0 中添加

Foldable   折叠式

Signature 签名

export declare const Foldable: Foldable1<'ReadonlyArray'>

Added in v2.7.0 v2.7.0 中添加

FoldableWithIndex   可折叠带索引

Signature 签名

export declare const FoldableWithIndex: FoldableWithIndex1<'ReadonlyArray', number>

Added in v2.7.0 v2.7.0 中添加

FromEither   来自任一

Signature 签名

export declare const FromEither: FromEither1<'ReadonlyArray'>

Added in v2.11.0 v2.11.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor1<'ReadonlyArray'>

Added in v2.7.0 v2.7.0 中添加

FunctorWithIndex   带索引的函子

Signature 签名

export declare const FunctorWithIndex: FunctorWithIndex1<'ReadonlyArray', number>

Added in v2.7.0 v2.7.0 中添加

Monad   单子

Signature 签名

export declare const Monad: Monad1<'ReadonlyArray'>

Added in v2.7.0 v2.7.0 中添加

Pointed  

Signature 签名

export declare const Pointed: Pointed1<'ReadonlyArray'>

Added in v2.10.0 v2.10.0 中添加

Traversable   可穿越

Signature 签名

export declare const Traversable: Traversable1<'ReadonlyArray'>

Added in v2.7.0 v2.7.0 中添加

TraversableWithIndex   可遍历索引

Signature 签名

export declare const TraversableWithIndex: TraversableWithIndex1<'ReadonlyArray', number>

Added in v2.7.0 v2.7.0 中添加

Unfoldable   可折叠

Signature 签名

export declare const Unfoldable: Unfoldable1<'ReadonlyArray'>

Added in v2.7.0 v2.7.0 中添加

Witherable   枯萎的

Signature 签名

export declare const Witherable: Witherable1<'ReadonlyArray'>

Added in v2.7.0 v2.7.0 中添加

Zero  

Signature 签名

export declare const Zero: Zero1<'ReadonlyArray'>

Added in v2.11.0 v2.11.0 中添加

getDifferenceMagma   获取差异岩浆

Signature 签名

export declare const getDifferenceMagma: <A>(E: Eq<A>) => Magma<readonly A[]>

Added in v2.11.0 v2.11.0 中添加

getEq   得到方程

Derives an Eq over the ReadonlyArray of a given element type from the Eq of that type. The derived Eq defines two arrays as equal if all elements of both arrays are compared equal pairwise with the given E. In case of arrays of different lengths, the result is non equality.
从给定元素类型的 Eq 派生出 Eq ,而不是该类型的 ReadonlyArray 。如果两个数组的所有元素与给定的 E 成对比较,则派生的 Eq 将两个数组定义为相等。如果数组长度不同,结果不相等。

Signature 签名

export declare const getEq: <A>(E: Eq<A>) => Eq<readonly A[]>

Example 例子

import * as S from 'fp-ts/string'
import { getEq } from 'fp-ts/ReadonlyArray'

const E = getEq(S.Eq)
assert.strictEqual(E.equals(['a', 'b'], ['a', 'b']), true)
assert.strictEqual(E.equals(['a'], []), false)

Added in v2.5.0 v2.5.0中添加

getIntersectionSemigroup
获取交集半群

Signature 签名

export declare const getIntersectionSemigroup: <A>(E: Eq<A>) => Semigroup<readonly A[]>

Added in v2.11.0 v2.11.0 中添加

getMonoid   获取Monoid

Returns a Monoid for ReadonlyArray<A>.
ReadonlyArray<A> 返回 Monoid

Signature 签名

export declare const getMonoid: <A = never>() => Monoid<readonly A[]>

Example 例子

import { getMonoid } from 'fp-ts/ReadonlyArray'

const M = getMonoid<number>()
assert.deepStrictEqual(M.concat([1, 2], [3, 4]), [1, 2, 3, 4])

Added in v2.5.0 v2.5.0中添加

getOrd   获取订单

Derives an Ord over the ReadonlyArray of a given element type from the Ord of that type. The ordering between two such arrays is equal to: the first non equal comparison of each arrays elements taken pairwise in increasing order, in case of equality over all the pairwise elements; the longest array is considered the greatest, if both arrays have the same length, the result is equality.
从给定元素类型的 Ord 派生出 Ord ,而不是该类型的 ReadonlyArray 。两个这样的数组之间的顺序等于:如果所有成对元素相等,则按升序对每个数组元素进行第一个不相等比较;最长的数组被认为是最大的,如果两个数组的长度相同,则结果相等。

Signature 签名

export declare const getOrd: <A>(O: Ord<A>) => Ord<readonly A[]>

Example 例子

import { getOrd } from 'fp-ts/ReadonlyArray'
import * as S from 'fp-ts/string'

const O = getOrd(S.Ord)
assert.strictEqual(O.compare(['b'], ['a']), 1)
assert.strictEqual(O.compare(['a'], ['a']), 0)
assert.strictEqual(O.compare(['a'], ['b']), -1)

Added in v2.5.0 v2.5.0中添加

getSemigroup   获取半群

Signature 签名

export declare const getSemigroup: <A = never>() => Semigroup<readonly A[]>

Added in v2.5.0 v2.5.0中添加

getShow   获取显示

Signature 签名

export declare const getShow: <A>(S: Show<A>) => Show<readonly A[]>

Added in v2.5.0 v2.5.0中添加

getUnionMonoid  获取UnionMonoid

Signature 签名

export declare const getUnionMonoid: <A>(E: Eq<A>) => Monoid<readonly A[]>

Added in v2.11.0 v2.11.0 中添加

getUnionSemigroup   获取UnionSemigroup

Signature 签名

export declare const getUnionSemigroup: <A>(E: Eq<A>) => Semigroup<readonly A[]>

Added in v2.11.0 v2.11.0 中添加

legacy   遗产

chain  

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chain: <A, B>(f: (a: A) => readonly B[]) => (ma: readonly A[]) => readonly B[]

Added in v2.5.0 v2.5.0中添加

lifting   起重

fromEitherK   来自EitherK

Signature 签名

export declare const fromEitherK: <E, A extends readonly unknown[], B>(
  f: (...a: A) => Either<E, B>
) => (...a: A) => readonly B[]

Added in v2.11.0 v2.11.0 中添加

fromOptionK   来自选项K

Signature 签名

export declare const fromOptionK: <A extends readonly unknown[], B>(
  f: (...a: A) => Option<B>
) => (...a: A) => readonly B[]

Added in v2.11.0 v2.11.0 中添加

fromPredicate   来自谓词

Signature 签名

export declare function fromPredicate<A, B extends A>(refinement: Refinement<A, B>): (a: A) => ReadonlyArray<B>
export declare function fromPredicate<A>(predicate: Predicate<A>): <B extends A>(b: B) => ReadonlyArray<B>
export declare function fromPredicate<A>(predicate: Predicate<A>): (a: A) => ReadonlyArray<A>

Added in v2.11.0 v2.11.0 中添加

mapping   映射

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <B>(fab: readonly ((a: A) => B)[]) => readonly B[]

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => (fa: readonly A[]) => readonly B[]

Added in v2.5.0 v2.5.0中添加

mapWithIndex   带索引的映射

Signature 签名

export declare const mapWithIndex: <A, B>(f: (i: number, a: A) => B) => (fa: readonly A[]) => readonly B[]

Added in v2.5.0 v2.5.0中添加

pattern matching   模式匹配

foldLeft   向左折叠

Alias of matchLeft.  matchLeft 的别名。

Signature 签名

export declare const foldLeft: <A, B>(
  onEmpty: LazyArg<B>,
  onNonEmpty: (head: A, tail: readonly A[]) => B
) => (as: readonly A[]) => B

Added in v2.5.0 v2.5.0中添加

foldRight   向右折叠

Alias of matchRight.  matchRight 的别名。

Signature 签名

export declare const foldRight: <A, B>(
  onEmpty: LazyArg<B>,
  onNonEmpty: (init: readonly A[], last: A) => B
) => (as: readonly A[]) => B

Added in v2.5.0 v2.5.0中添加

match   匹配

Signature 签名

export declare const match: <B, A>(
  onEmpty: LazyArg<B>,
  onNonEmpty: (as: RNEA.ReadonlyNonEmptyArray<A>) => B
) => (as: readonly A[]) => B

Added in v2.11.0 v2.11.0 中添加

matchLeft   左匹配

Break a ReadonlyArray into its first element and remaining elements.
ReadonlyArray 分解为其第一个元素和其余元素。

Signature 签名

export declare const matchLeft: <B, A>(
  onEmpty: LazyArg<B>,
  onNonEmpty: (head: A, tail: readonly A[]) => B
) => (as: readonly A[]) => B

Example 例子

import { matchLeft } from 'fp-ts/ReadonlyArray'

const len: <A>(as: ReadonlyArray<A>) => number = matchLeft(
  () => 0,
  (_, tail) => 1 + len(tail)
)
assert.strictEqual(len([1, 2, 3]), 3)

Added in v2.10.0 v2.10.0 中添加

matchLeftW   左匹配W

Less strict version of matchLeft.
matchLeft 的不太严格版本。

Signature 签名

export declare const matchLeftW: <B, A, C>(
  onEmpty: LazyArg<B>,
  onNonEmpty: (head: A, tail: readonly A[]) => C
) => (as: readonly A[]) => B | C

Added in v2.11.0 v2.11.0 中添加

matchRight   右匹配

Break a ReadonlyArray into its initial elements and the last element.
ReadonlyArray 分解为其初始元素和最后一个元素。

Signature 签名

export declare const matchRight: <B, A>(
  onEmpty: LazyArg<B>,
  onNonEmpty: (init: readonly A[], last: A) => B
) => (as: readonly A[]) => B

Added in v2.10.0 v2.10.0 中添加

matchRightW   匹配右W

Less strict version of matchRight.
matchRight 的不太严格版本。

Signature 签名

export declare const matchRightW: <B, A, C>(
  onEmpty: LazyArg<B>,
  onNonEmpty: (init: readonly A[], last: A) => C
) => (as: readonly A[]) => B | C

Added in v2.11.0 v2.11.0 中添加

matchW   匹配W

Less strict version of match.
match 的不太严格版本。

The W suffix (short for Widening) means that the handler return types will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const matchW: <B, A, C>(
  onEmpty: LazyArg<B>,
  onNonEmpty: (as: RNEA.ReadonlyNonEmptyArray<A>) => C
) => (as: readonly A[]) => B | C

Added in v2.11.0 v2.11.0 中添加

refinements   改进

isEmpty   是空的

Test whether a ReadonlyArray is empty.
测试 ReadonlyArray 是否为空。

Signature 签名

export declare const isEmpty: <A>(as: readonly A[]) => as is readonly []

Example 例子

import { isEmpty } from 'fp-ts/ReadonlyArray'

assert.strictEqual(isEmpty([]), true)

Added in v2.5.0 v2.5.0中添加

isNonEmpty   为非空

Test whether a ReadonlyArray is non empty.
测试 ReadonlyArray 是否非空。

Signature 签名

export declare const isNonEmpty: <A>(as: readonly A[]) => as is RNEA.ReadonlyNonEmptyArray<A>

Added in v2.5.0 v2.5.0中添加

sequencing   测序

chainFirst   链优先

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const chainFirst: <A, B>(f: (a: A) => readonly B[]) => (first: readonly A[]) => readonly A[]

Example 例子

import * as RA from 'fp-ts/ReadonlyArray'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(
  pipe(
    [1, 2, 3],
    RA.chainFirst(() => ['a', 'b'])
  ),
  [1, 1, 2, 2, 3, 3]
)
assert.deepStrictEqual(
  pipe(
    [1, 2, 3],
    RA.chainFirst(() => [])
  ),
  []
)

Added in v2.5.0 v2.5.0中添加

chainRecBreadthFirst   链记录宽度优先

Signature 签名

export declare const chainRecBreadthFirst: <A, B>(f: (a: A) => readonly Either<A, B>[]) => (a: A) => readonly B[]

Added in v2.11.0 v2.11.0 中添加

chainRecDepthFirst   链记录深度优先

Signature 签名

export declare const chainRecDepthFirst: <A, B>(f: (a: A) => readonly Either<A, B>[]) => (a: A) => readonly B[]

Added in v2.11.0 v2.11.0 中添加

chainWithIndex   带索引的链

Signature 签名

export declare const chainWithIndex: <A, B>(f: (i: number, a: A) => readonly B[]) => (as: readonly A[]) => readonly B[]

Added in v2.7.0 v2.7.0 中添加

flatMap   平面地图

Composes computations in sequence, using the return value of one computation to determine the next computation.
按顺序组成计算,使用一次计算的返回值来确定下一次计算。

Signature 签名

export declare const flatMap: {
  <A, B>(f: (a: A, i: number) => readonly B[]): (ma: readonly A[]) => readonly B[]
  <A, B>(ma: readonly A[], f: (a: A, i: number) => readonly B[]): readonly B[]
}

Example 例子

import * as RA from 'fp-ts/ReadonlyArray'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(
  pipe(
    [1, 2, 3],
    RA.flatMap((n) => [`a${n}`, `b${n}`])
  ),
  ['a1', 'b1', 'a2', 'b2', 'a3', 'b3']
)
assert.deepStrictEqual(
  pipe(
    [1, 2, 3],
    RA.flatMap(() => [])
  ),
  []
)

Added in v2.14.0 v2.14.0 中添加

flatten   压扁

Signature 签名

export declare const flatten: <A>(mma: readonly (readonly A[])[]) => readonly A[]

Added in v2.5.0 v2.5.0中添加

traverseWithIndex   索引遍历

Signature 签名

export declare const traverseWithIndex: PipeableTraverseWithIndex1<'ReadonlyArray', number>

Added in v2.6.3 v2.6.3 中添加

traversing   穿越

sequence   顺序

Signature 签名

export declare const sequence: Sequence1<'ReadonlyArray'>

Added in v2.6.3 v2.6.3 中添加

traverse   遍历

Signature 签名

export declare const traverse: PipeableTraverse1<'ReadonlyArray'>

Added in v2.6.3 v2.6.3 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'ReadonlyArray'

Added in v2.5.0 v2.5.0中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.5.0 v2.5.0中添加

unsafe   不安全

unsafeDeleteAt  不安全删除

Signature 签名

export declare const unsafeDeleteAt: <A>(i: number, as: readonly A[]) => readonly A[]

Added in v2.5.0 v2.5.0中添加

unsafeInsertAt   不安全插入

Signature 签名

export declare const unsafeInsertAt: <A>(i: number, a: A, as: readonly A[]) => RNEA.ReadonlyNonEmptyArray<A>

Added in v2.5.0 v2.5.0中添加

unsafeUpdateAt  不安全更新处

Signature 签名

export declare const unsafeUpdateAt: <A>(i: number, a: A, as: readonly A[]) => readonly A[]

Added in v2.5.0 v2.5.0中添加

utils   实用程序

Spanned (interface)   跨越(接口)

Signature 签名

export interface Spanned<I, R> {
  readonly init: ReadonlyArray<I>
  readonly rest: ReadonlyArray<R>
}

Added in v2.5.0 v2.5.0中添加

ap   美联社

Signature 签名

export declare const ap: <A>(fa: readonly A[]) => <B>(fab: readonly ((a: A) => B)[]) => readonly B[]

Added in v2.5.0 v2.5.0中添加

apFirst   应用程序第一

Combine two effectful actions, keeping only the result of the first.
结合两个有效的操作,仅保留第一个操作的结果。

Signature 签名

export declare const apFirst: <B>(second: readonly B[]) => <A>(first: readonly A[]) => readonly A[]

Added in v2.5.0 v2.5.0中添加

apSecond   ap秒

Combine two effectful actions, keeping only the result of the second.
结合两个有效的操作,只保留第二个的结果。

Signature 签名

export declare const apSecond: <B>(second: readonly B[]) => <A>(first: readonly A[]) => readonly B[]

Added in v2.5.0 v2.5.0中添加

append   附加

Append an element to the end of a ReadonlyArray, creating a new ReadonlyNonEmptyArray.
将一个元素附加到 ReadonlyArray 的末尾,创建一个新的 ReadonlyNonEmptyArray

Signature 签名

export declare const append: <A>(end: A) => (init: readonly A[]) => RNEA.ReadonlyNonEmptyArray<A>

Example 例子

import { append } from 'fp-ts/ReadonlyArray'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe([1, 2, 3], append(4)), [1, 2, 3, 4])

Added in v2.10.0 v2.10.0 中添加

appendW   追加W

Less strict version of append.
append 的不太严格版本。

Signature 签名

export declare const appendW: <B>(end: B) => <A>(init: readonly A[]) => RNEA.ReadonlyNonEmptyArray<B | A>

Added in v2.11.0 v2.11.0 中添加

chop  

A useful recursion pattern for processing a ReadonlyArray to produce a new ReadonlyArray, often used for “chopping” up the input ReadonlyArray. Typically chop is called with some function that will consume an initial prefix of the ReadonlyArray and produce a value and the tail of the ReadonlyArray.
一种有用的递归模式,用于处理 ReadonlyArray 以生成新的 ReadonlyArray ,通常用于“切碎”输入 ReadonlyArray 。通常, chop 是通过某个函数调用的,该函数将消耗 ReadonlyArray 的初始前缀并生成一个值和 ReadonlyArray 的尾部。

Signature 签名

export declare const chop: <A, B>(
  f: (as: RNEA.ReadonlyNonEmptyArray<A>) => readonly [B, readonly A[]]
) => (as: readonly A[]) => readonly B[]

Example 例子

import { Eq } from 'fp-ts/Eq'
import * as RA from 'fp-ts/ReadonlyArray'
import * as N from 'fp-ts/number'
import { pipe } from 'fp-ts/function'

const group = <A>(S: Eq<A>): ((as: ReadonlyArray<A>) => ReadonlyArray<ReadonlyArray<A>>) => {
  return RA.chop((as) => {
    const { init, rest } = pipe(
      as,
      RA.spanLeft((a: A) => S.equals(a, as[0]))
    )
    return [init, rest]
  })
}
assert.deepStrictEqual(group(N.Eq)([1, 1, 2, 3, 3, 4]), [[1, 1], [2], [3, 3], [4]])

Added in v2.5.0 v2.5.0中添加

chunksOf   大块

Splits a ReadonlyArray into length-n pieces. The last piece will be shorter if n does not evenly divide the length of the ReadonlyArray. Note that chunksOf(n)([]) is [], not [[]]. This is intentional, and is consistent with a recursive definition of chunksOf; it satisfies the property that:
ReadonlyArray 分割成长度为 n 的片段。如果 n 没有平分 ReadonlyArray 的长度,那么最后一段会更短。请注意, chunksOf(n)([])[] ,而不是 [[]] 。这是故意的,并且与 chunksOf 的递归定义一致;它满足以下性质:

chunksOf(n)(xs).concat(chunksOf(n)(ys)) == chunksOf(n)(xs.concat(ys)))

whenever n evenly divides the length of as.
每当 n 均分 as 的长度时。

Signature 签名

export declare const chunksOf: (n: number) => <A>(as: readonly A[]) => readonly RNEA.ReadonlyNonEmptyArray<A>[]

Example 例子

import { chunksOf } from 'fp-ts/ReadonlyArray'

assert.deepStrictEqual(chunksOf(2)([1, 2, 3, 4, 5]), [[1, 2], [3, 4], [5]])

Added in v2.5.0 v2.5.0中添加

comprehension   理解

ReadonlyArray comprehension.

[ f(x, y, ...) | x ← xs, y ← ys, ..., g(x, y, ...) ]

Signature 签名

export declare function comprehension<A, B, C, D, R>(
  input: readonly [ReadonlyArray<A>, ReadonlyArray<B>, ReadonlyArray<C>, ReadonlyArray<D>],
  f: (a: A, b: B, c: C, d: D) => R,
  g?: (a: A, b: B, c: C, d: D) => boolean
): ReadonlyArray<R>
export declare function comprehension<A, B, C, R>(
  input: readonly [ReadonlyArray<A>, ReadonlyArray<B>, ReadonlyArray<C>],
  f: (a: A, b: B, c: C) => R,
  g?: (a: A, b: B, c: C) => boolean
): ReadonlyArray<R>
export declare function comprehension<A, B, R>(
  input: readonly [ReadonlyArray<A>, ReadonlyArray<B>],
  f: (a: A, b: B) => R,
  g?: (a: A, b: B) => boolean
): ReadonlyArray<R>
export declare function comprehension<A, R>(
  input: readonly [ReadonlyArray<A>],
  f: (a: A) => R,
  g?: (a: A) => boolean
): ReadonlyArray<R>

Example 例子

import { comprehension } from 'fp-ts/ReadonlyArray'
import { tuple } from 'fp-ts/function'

assert.deepStrictEqual(
  comprehension(
    [
      [1, 2, 3],
      ['a', 'b'],
    ],
    tuple,
    (a, b) => (a + b.length) % 2 === 0
  ),
  [
    [1, 'a'],
    [1, 'b'],
    [3, 'a'],
    [3, 'b'],
  ]
)

Added in v2.5.0 v2.5.0中添加

concat   连接

Signature 签名

export declare const concat: <A>(second: readonly A[]) => (first: readonly A[]) => readonly A[]

Added in v2.11.0 v2.11.0 中添加

concatW   连接W

Signature 签名

export declare const concatW: <B>(second: readonly B[]) => <A>(first: readonly A[]) => readonly (B | A)[]

Added in v2.11.0 v2.11.0 中添加

deleteAt   删除处

Delete the element at the specified index, creating a new array, or returning None if the index is out of bounds
删除指定索引处的元素,创建新数组,如果索引越界则返回 None

Signature 签名

export declare const deleteAt: (i: number) => <A>(as: readonly A[]) => Option<readonly A[]>

Example 例子

import { deleteAt } from 'fp-ts/ReadonlyArray'
import { some, none } from 'fp-ts/Option'

assert.deepStrictEqual(deleteAt(0)([1, 2, 3]), some([2, 3]))
assert.deepStrictEqual(deleteAt(1)([]), none)

Added in v2.5.0 v2.5.0中添加

difference   不同之处

Creates an array of array values not included in the other given array using a Eq for equality comparisons. The order and references of result values are determined by the first array.
使用 Eq 创建不包含在其他给定数组中的数组值进行相等比较。结果值的顺序和引用由第一个数组确定。

Signature 签名

export declare function difference<A>(E: Eq<A>): {
  (xs: ReadonlyArray<A>): (ys: ReadonlyArray<A>) => ReadonlyArray<A>
  (xs: ReadonlyArray<A>, ys: ReadonlyArray<A>): ReadonlyArray<A>
}

Example 例子

import { difference } from 'fp-ts/ReadonlyArray'
import * as N from 'fp-ts/number'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe([1, 2], difference(N.Eq)([2, 3])), [1])

Added in v2.5.0 v2.5.0中添加

dropLeft   向左下降

Drop a max number of elements from the start of an ReadonlyArray, creating a new ReadonlyArray.
ReadonlyArray 开头删除最大数量的元素,创建新的 ReadonlyArray

Note. n is normalized to a non negative integer.
笔记。 n 被标准化为非负整数。

Signature 签名

export declare const dropLeft: (n: number) => <A>(as: readonly A[]) => readonly A[]

Example 例子

import * as RA from 'fp-ts/ReadonlyArray'
import { pipe } from 'fp-ts/function'

const input: ReadonlyArray<number> = [1, 2, 3]
assert.deepStrictEqual(pipe(input, RA.dropLeft(2)), [3])
assert.strictEqual(pipe(input, RA.dropLeft(0)), input)
assert.strictEqual(pipe(input, RA.dropLeft(-1)), input)

Added in v2.5.0 v2.5.0中添加

dropLeftWhile   向左下降

Remove the longest initial subarray for which all element satisfy the specified predicate, creating a new array
删除所有元素满足指定谓词的最长初始子数组,创建一个新数组

Signature 签名

export declare function dropLeftWhile<A, B extends A>(
  refinement: Refinement<A, B>
): (as: ReadonlyArray<A>) => ReadonlyArray<B>
export declare function dropLeftWhile<A>(
  predicate: Predicate<A>
): <B extends A>(bs: ReadonlyArray<B>) => ReadonlyArray<B>
export declare function dropLeftWhile<A>(predicate: Predicate<A>): (as: ReadonlyArray<A>) => ReadonlyArray<A>

Example 例子

import { dropLeftWhile } from 'fp-ts/ReadonlyArray'

assert.deepStrictEqual(dropLeftWhile((n: number) => n % 2 === 1)([1, 3, 2, 4, 5]), [2, 4, 5])

Added in v2.5.0 v2.5.0中添加

dropRight   向右下降

Drop a max number of elements from the end of an ReadonlyArray, creating a new ReadonlyArray.
ReadonlyArray 末尾删除最大数量的元素,创建新的 ReadonlyArray

Note. n is normalized to a non negative integer.
笔记。 n 被标准化为非负整数。

Signature 签名

export declare const dropRight: (n: number) => <A>(as: readonly A[]) => readonly A[]

Example 例子

import * as RA from 'fp-ts/ReadonlyArray'
import { pipe } from 'fp-ts/function'

const input: ReadonlyArray<number> = [1, 2, 3]
assert.deepStrictEqual(pipe(input, RA.dropRight(2)), [1])
assert.strictEqual(pipe(input, RA.dropRight(0)), input)
assert.strictEqual(pipe(input, RA.dropRight(-1)), input)

Added in v2.5.0 v2.5.0中添加

duplicate   复制

Signature 签名

export declare const duplicate: <A>(wa: readonly A[]) => readonly (readonly A[])[]

Added in v2.5.0 v2.5.0中添加

elem   埃莱姆

Test if a value is a member of an array. Takes a Eq<A> as a single argument which returns the function to use to search for a value of type A in an array of type ReadonlyArray<A>.
测试一个值是否是数组的成员。将 Eq<A> 作为单个参数,该参数返回用于在 ReadonlyArray<A> 类型的数组中搜索 A 类型的值的函数。

Signature 签名

export declare function elem<A>(E: Eq<A>): {
  (a: A): (as: ReadonlyArray<A>) => boolean
  (a: A, as: ReadonlyArray<A>): boolean
}

Example 例子

import { elem } from 'fp-ts/ReadonlyArray'
import * as N from 'fp-ts/number'
import { pipe } from 'fp-ts/function'

assert.strictEqual(pipe([1, 2, 3], elem(N.Eq)(2)), true)
assert.strictEqual(pipe([1, 2, 3], elem(N.Eq)(0)), false)

Added in v2.5.0 v2.5.0中添加

empty   空的

An empty array 空数组

Signature 签名

export declare const empty: readonly never[]

Added in v2.5.0 v2.5.0中添加

every   每一个

Check if a predicate holds true for every array member.
检查谓词是否对每个数组成员都成立。

Signature 签名

export declare function every<A, B extends A>(
  refinement: Refinement<A, B>
): Refinement<ReadonlyArray<A>, ReadonlyArray<B>>
export declare function every<A>(predicate: Predicate<A>): Predicate<ReadonlyArray<A>>

Example 例子

import { every } from 'fp-ts/ReadonlyArray'
import { pipe } from 'fp-ts/function'

const isPositive = (n: number): boolean => n > 0

assert.deepStrictEqual(pipe([1, 2, 3], every(isPositive)), true)
assert.deepStrictEqual(pipe([1, 2, -3], every(isPositive)), false)

Added in v2.9.0 v2.9.0中添加

exists   存在

Alias of some  some 的别名

Signature 签名

export declare const exists: <A>(predicate: Predicate<A>) => (as: readonly A[]) => as is RNEA.ReadonlyNonEmptyArray<A>

Added in v2.11.0 v2.11.0 中添加

extend   延长

Signature 签名

export declare const extend: <A, B>(f: (fa: readonly A[]) => B) => (wa: readonly A[]) => readonly B[]

Added in v2.5.0 v2.5.0中添加

filterE   过滤器E

Filter values inside a context.
过滤上下文中的值。

Signature 签名

export declare const filterE: FilterE1<'ReadonlyArray'>

Example 例子

import { pipe } from 'fp-ts/function'
import * as RA from 'fp-ts/ReadonlyArray'
import * as T from 'fp-ts/Task'

const filterE = RA.filterE(T.ApplicativePar)
async function test() {
  assert.deepStrictEqual(
    await pipe(
      [-1, 2, 3],
      filterE((n) => T.of(n > 0))
    )(),
    [2, 3]
  )
}
test()

Added in v2.11.0 v2.11.0 中添加

findFirst   查找第一个

Find the first element which satisfies a predicate (or a refinement) function
查找满足谓词(或细化)函数的第一个元素

Signature 签名

export declare function findFirst<A, B extends A>(refinement: Refinement<A, B>): (as: ReadonlyArray<A>) => Option<B>
export declare function findFirst<A>(predicate: Predicate<A>): <B extends A>(bs: ReadonlyArray<B>) => Option<B>
export declare function findFirst<A>(predicate: Predicate<A>): (as: ReadonlyArray<A>) => Option<A>

Example 例子

import { findFirst } from 'fp-ts/ReadonlyArray'
import { some } from 'fp-ts/Option'

type X = {
  readonly a: number
  readonly b: number
}

assert.deepStrictEqual(
  findFirst((x: X) => x.a === 1)([
    { a: 1, b: 1 },
    { a: 1, b: 2 },
  ]),
  some({ a: 1, b: 1 })
)

Added in v2.5.0 v2.5.0中添加

findFirstMap   查找第一张地图

Find the first element returned by an option based selector function
查找基于选项的选择器函数返回的第一个元素

Signature 签名

export declare const findFirstMap: <A, B>(f: (a: A) => Option<B>) => (as: readonly A[]) => Option<B>

Example 例子

import { findFirstMap } from 'fp-ts/ReadonlyArray'
import { some, none } from 'fp-ts/Option'

interface Person {
  readonly name: string
  readonly age?: number
}

const persons: ReadonlyArray<Person> = [{ name: 'John' }, { name: 'Mary', age: 45 }, { name: 'Joey', age: 28 }]

// returns the name of the first person that has an age
assert.deepStrictEqual(findFirstMap((p: Person) => (p.age === undefined ? none : some(p.name)))(persons), some('Mary'))

Added in v2.5.0 v2.5.0中添加

findIndex   查找索引

Find the first index for which a predicate holds
查找谓词所包含的第一个索引

Signature 签名

export declare const findIndex: <A>(predicate: Predicate<A>) => (as: readonly A[]) => Option<number>

Example 例子

import { findIndex } from 'fp-ts/ReadonlyArray'
import { some, none } from 'fp-ts/Option'

assert.deepStrictEqual(findIndex((n: number) => n === 2)([1, 2, 3]), some(1))
assert.deepStrictEqual(findIndex((n: number) => n === 2)([]), none)

Added in v2.5.0 v2.5.0中添加

findLast   查找最后一个

Find the last element which satisfies a predicate function
查找满足谓词函数的最后一个元素

Signature 签名

export declare function findLast<A, B extends A>(refinement: Refinement<A, B>): (as: ReadonlyArray<A>) => Option<B>
export declare function findLast<A>(predicate: Predicate<A>): <B extends A>(bs: ReadonlyArray<B>) => Option<B>
export declare function findLast<A>(predicate: Predicate<A>): (as: ReadonlyArray<A>) => Option<A>

Example 例子

import { findLast } from 'fp-ts/ReadonlyArray'
import { some } from 'fp-ts/Option'

type X = {
  readonly a: number
  readonly b: number
}

assert.deepStrictEqual(
  findLast((x: X) => x.a === 1)([
    { a: 1, b: 1 },
    { a: 1, b: 2 },
  ]),
  some({ a: 1, b: 2 })
)

Added in v2.5.0 v2.5.0中添加

findLastIndex  查找最后一个索引

Returns the index of the last element of the list which matches the predicate
返回列表中与谓词匹配的最后一个元素的索引

Signature 签名

export declare const findLastIndex: <A>(predicate: Predicate<A>) => (as: readonly A[]) => Option<number>

Example 例子

import { findLastIndex } from 'fp-ts/ReadonlyArray'
import { some, none } from 'fp-ts/Option'

interface X {
  readonly a: number
  readonly b: number
}
const xs: ReadonlyArray<X> = [
  { a: 1, b: 0 },
  { a: 1, b: 1 },
]
assert.deepStrictEqual(findLastIndex((x: { readonly a: number }) => x.a === 1)(xs), some(1))
assert.deepStrictEqual(findLastIndex((x: { readonly a: number }) => x.a === 4)(xs), none)

Added in v2.5.0 v2.5.0中添加

findLastMap   查找最后一个地图

Find the last element returned by an option based selector function
查找基于选项的选择器函数返回的最后一个元素

Signature 签名

export declare const findLastMap: <A, B>(f: (a: A) => Option<B>) => (as: readonly A[]) => Option<B>

Example 例子

import { findLastMap } from 'fp-ts/ReadonlyArray'
import { some, none } from 'fp-ts/Option'

interface Person {
  readonly name: string
  readonly age?: number
}

const persons: ReadonlyArray<Person> = [{ name: 'John' }, { name: 'Mary', age: 45 }, { name: 'Joey', age: 28 }]

// returns the name of the last person that has an age
assert.deepStrictEqual(findLastMap((p: Person) => (p.age === undefined ? none : some(p.name)))(persons), some('Joey'))

Added in v2.5.0 v2.5.0中添加

Get the first element in an array, or None if the array is empty
获取数组中的第一个元素,如果数组为空则获取 None

Signature 签名

export declare const head: <A>(as: readonly A[]) => Option<A>

Example 例子

import { head } from 'fp-ts/ReadonlyArray'
import { some, none } from 'fp-ts/Option'

assert.deepStrictEqual(head([1, 2, 3]), some(1))
assert.deepStrictEqual(head([]), none)

Added in v2.5.0 v2.5.0中添加

init   在里面

Get all but the last element of an array, creating a new array, or None if the array is empty
获取数组中除最后一个元素之外的所有元素,创建一个新数组,如果数组为空则为 None

Signature 签名

export declare const init: <A>(as: readonly A[]) => Option<readonly A[]>

Example 例子

import { init } from 'fp-ts/ReadonlyArray'
import { some, none } from 'fp-ts/Option'

assert.deepStrictEqual(init([1, 2, 3]), some([1, 2]))
assert.deepStrictEqual(init([]), none)

Added in v2.5.0 v2.5.0中添加

insertAt   插入位置

Insert an element at the specified index, creating a new array, or returning None if the index is out of bounds
在指定索引处插入元素,创建新数组,如果索引越界则返回 None

Signature 签名

export declare const insertAt: <A>(i: number, a: A) => (as: readonly A[]) => Option<RNEA.ReadonlyNonEmptyArray<A>>

Example 例子

import { insertAt } from 'fp-ts/ReadonlyArray'
import { some } from 'fp-ts/Option'

assert.deepStrictEqual(insertAt(2, 5)([1, 2, 3, 4]), some([1, 2, 5, 3, 4]))

Added in v2.5.0 v2.5.0中添加

intercalate  

Places an element in between members of a ReadonlyArray, then folds the results using the provided Monoid.
将一个元素放置在 ReadonlyArray 的成员之间,然后使用提供的 Monoid 折叠结果。

Signature 签名

export declare const intercalate: <A>(M: Monoid<A>) => (middle: A) => (as: readonly A[]) => A

Example 例子

import * as S from 'fp-ts/string'
import { intercalate } from 'fp-ts/ReadonlyArray'

assert.deepStrictEqual(intercalate(S.Monoid)('-')(['a', 'b', 'c']), 'a-b-c')

Added in v2.12.0 v2.12.0 中添加

intersection   路口

Creates an array of unique values that are included in all given arrays using a Eq for equality comparisons. The order and references of result values are determined by the first array.
创建一个包含在所有给定数组中的唯一值数组,使用 Eq 进行相等比较。结果值的顺序和引用由第一个数组确定。

Signature 签名

export declare function intersection<A>(E: Eq<A>): {
  (xs: ReadonlyArray<A>): (ys: ReadonlyArray<A>) => ReadonlyArray<A>
  (xs: ReadonlyArray<A>, ys: ReadonlyArray<A>): ReadonlyArray<A>
}

Example 例子

import { intersection } from 'fp-ts/ReadonlyArray'
import * as N from 'fp-ts/number'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe([1, 2], intersection(N.Eq)([2, 3])), [2])

Added in v2.5.0 v2.5.0中添加

intersperse   散布

Places an element in between members of an array
将元素放置在数组成员之间

Signature 签名

export declare const intersperse: <A>(middle: A) => (as: readonly A[]) => readonly A[]

Example 例子

import { intersperse } from 'fp-ts/ReadonlyArray'

assert.deepStrictEqual(intersperse(9)([1, 2, 3, 4]), [1, 9, 2, 9, 3, 9, 4])

Added in v2.9.0 v2.9.0中添加

isOutOfBound   超出界限

Test whether an array contains a particular index
测试数组是否包含特定索引

Signature 签名

export declare const isOutOfBound: <A>(i: number, as: readonly A[]) => boolean

Added in v2.5.0 v2.5.0中添加

last   最后的

Get the last element in an array, or None if the array is empty
获取数组中的最后一个元素,如果数组为空,则获取 None

Signature 签名

export declare const last: <A>(as: readonly A[]) => Option<A>

Example 例子

import { last } from 'fp-ts/ReadonlyArray'
import { some, none } from 'fp-ts/Option'

assert.deepStrictEqual(last([1, 2, 3]), some(3))
assert.deepStrictEqual(last([]), none)

Added in v2.5.0 v2.5.0中添加

lefts   左派

Extracts from an array of Either all the Left elements. All the Left elements are extracted in order
Either 数组中提取所有 Left 元素。所有 Left 元素按顺序提取

Signature 签名

export declare const lefts: <E, A>(as: readonly Either<E, A>[]) => readonly E[]

Example 例子

import { lefts } from 'fp-ts/ReadonlyArray'
import { left, right } from 'fp-ts/Either'

assert.deepStrictEqual(lefts([right(1), left('foo'), right(2)]), ['foo'])

Added in v2.5.0 v2.5.0中添加

lookup   抬头

This function provides a safe way to read a value at a particular index from an array
此函数提供了一种从数组中读取特定索引处的值的安全方法

Signature 签名

export declare function lookup(i: number): <A>(as: ReadonlyArray<A>) => Option<A>
export declare function lookup<A>(i: number, as: ReadonlyArray<A>): Option<A>

Example 例子

import { lookup } from 'fp-ts/ReadonlyArray'
import { some, none } from 'fp-ts/Option'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe([1, 2, 3], lookup(1)), some(2))
assert.deepStrictEqual(pipe([1, 2, 3], lookup(3)), none)

Added in v2.5.0 v2.5.0中添加

modifyAt   修改处

Apply a function to the element at the specified index, creating a new array, or returning None if the index is out of bounds
将函数应用于指定索引处的元素,创建一个新数组,或者如果索引越界则返回 None

Signature 签名

export declare const modifyAt: <A>(i: number, f: (a: A) => A) => (as: readonly A[]) => Option<readonly A[]>

Example 例子

import { modifyAt } from 'fp-ts/ReadonlyArray'
import { some, none } from 'fp-ts/Option'

const double = (x: number): number => x * 2
assert.deepStrictEqual(modifyAt(1, double)([1, 2, 3]), some([1, 4, 3]))
assert.deepStrictEqual(modifyAt(1, double)([]), none)

Added in v2.5.0 v2.5.0中添加

prepend   前置

Prepend an element to the front of a ReadonlyArray, creating a new ReadonlyNonEmptyArray.
ReadonlyArray 前面添加一个元素,创建一个新的 ReadonlyNonEmptyArray

Signature 签名

export declare const prepend: <A>(head: A) => (tail: readonly A[]) => RNEA.ReadonlyNonEmptyArray<A>

Example 例子

import { prepend } from 'fp-ts/ReadonlyArray'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe([2, 3, 4], prepend(1)), [1, 2, 3, 4])

Added in v2.10.0 v2.10.0 中添加

prependAll   前置所有

Prepend an element to every member of an array
为数组的每个成员添加一个元素

Signature 签名

export declare const prependAll: <A>(middle: A) => (as: readonly A[]) => readonly A[]

Example 例子

import { prependAll } from 'fp-ts/ReadonlyArray'

assert.deepStrictEqual(prependAll(9)([1, 2, 3, 4]), [9, 1, 9, 2, 9, 3, 9, 4])

Added in v2.10.0 v2.10.0 中添加

prependW   前置W

Less strict version of prepend.
prepend 的不太严格版本。

Signature 签名

export declare const prependW: <B>(head: B) => <A>(tail: readonly A[]) => RNEA.ReadonlyNonEmptyArray<B | A>

Added in v2.11.0 v2.11.0 中添加

reverse   撤销

Reverse an array, creating a new array
反转数组,创建一个新数组

Signature 签名

export declare const reverse: <A>(as: readonly A[]) => readonly A[]

Example 例子

import { reverse } from 'fp-ts/ReadonlyArray'

assert.deepStrictEqual(reverse([1, 2, 3]), [3, 2, 1])

Added in v2.5.0 v2.5.0中添加

rights   权利

Extracts from an array of Either all the Right elements. All the Right elements are extracted in order
Either 数组中提取所有 Right 元素。所有 Right 元素按顺序提取

Signature 签名

export declare const rights: <E, A>(as: readonly Either<E, A>[]) => readonly A[]

Example 例子

import { rights } from 'fp-ts/ReadonlyArray'
import { right, left } from 'fp-ts/Either'

assert.deepStrictEqual(rights([right(1), left('foo'), right(2)]), [1, 2])

Added in v2.5.0 v2.5.0中添加

rotate   旋转

Rotate a ReadonlyArray by n steps.
ReadonlyArray 旋转 n 步。

Signature 签名

export declare const rotate: (n: number) => <A>(as: readonly A[]) => readonly A[]

Example 例子

import { rotate } from 'fp-ts/ReadonlyArray'

assert.deepStrictEqual(rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])

Added in v2.5.0 v2.5.0中添加

scanLeft   向左扫描

Same as reduce but it carries over the intermediate steps.
reduce 相同,但它延续了中间步骤。

Signature 签名

export declare const scanLeft: <A, B>(b: B, f: (b: B, a: A) => B) => (as: readonly A[]) => RNEA.ReadonlyNonEmptyArray<B>

Example 例子

import { scanLeft } from 'fp-ts/ReadonlyArray'

assert.deepStrictEqual(scanLeft(10, (b, a: number) => b - a)([1, 2, 3]), [10, 9, 7, 4])

Added in v2.5.0 v2.5.0中添加

scanRight   右扫描

Fold an array from the right, keeping all intermediate results instead of only the final result
从右侧折叠数组,保留所有中间结果而不是仅保留最终结果

Signature 签名

export declare const scanRight: <A, B>(
  b: B,
  f: (a: A, b: B) => B
) => (as: readonly A[]) => RNEA.ReadonlyNonEmptyArray<B>

Example 例子

import { scanRight } from 'fp-ts/ReadonlyArray'

assert.deepStrictEqual(scanRight(10, (a: number, b) => b - a)([1, 2, 3]), [4, 5, 7, 10])

Added in v2.5.0 v2.5.0中添加

size   尺寸

Calculate the number of elements in a ReadonlyArray.
计算 ReadonlyArray 中的元素数量。

Signature 签名

export declare const size: <A>(as: readonly A[]) => number

Added in v2.10.0 v2.10.0 中添加

some   一些

Check if a predicate holds true for any array member.
检查谓词对于任何数组成员是否成立。

Signature 签名

export declare const some: <A>(predicate: Predicate<A>) => (as: readonly A[]) => as is RNEA.ReadonlyNonEmptyArray<A>

Example 例子

import { some } from 'fp-ts/ReadonlyArray'
import { pipe } from 'fp-ts/function'

const isPositive = (n: number): boolean => n > 0

assert.deepStrictEqual(pipe([-1, -2, 3], some(isPositive)), true)
assert.deepStrictEqual(pipe([-1, -2, -3], some(isPositive)), false)

Added in v2.9.0 v2.9.0中添加

sort   种类

Sort the elements of an array in increasing order, creating a new array
将数组元素按升序排序,创建一个新数组

Signature 签名

export declare const sort: <B>(O: Ord<B>) => <A extends B>(as: readonly A[]) => readonly A[]

Example 例子

import { sort } from 'fp-ts/ReadonlyArray'
import * as N from 'fp-ts/number'

assert.deepStrictEqual(sort(N.Ord)([3, 2, 1]), [1, 2, 3])

Added in v2.5.0 v2.5.0中添加

sortBy   排序方式

Sort the elements of an array in increasing order, where elements are compared using first ords[0], then ords[1], etc…
按升序对数组的元素进行排序,其中首先使用 ords[0] ,然后使用 ords[1] 等比较元素......

Signature 签名

export declare const sortBy: <B>(ords: readonly Ord<B>[]) => <A extends B>(as: readonly A[]) => readonly A[]

Example 例子

import { sortBy } from 'fp-ts/ReadonlyArray'
import { contramap } from 'fp-ts/Ord'
import * as S from 'fp-ts/string'
import * as N from 'fp-ts/number'
import { pipe } from 'fp-ts/function'

interface Person {
  readonly name: string
  readonly age: number
}
const byName = pipe(
  S.Ord,
  contramap((p: Person) => p.name)
)
const byAge = pipe(
  N.Ord,
  contramap((p: Person) => p.age)
)

const sortByNameByAge = sortBy([byName, byAge])

const persons = [
  { name: 'a', age: 1 },
  { name: 'b', age: 3 },
  { name: 'c', age: 2 },
  { name: 'b', age: 2 },
]
assert.deepStrictEqual(sortByNameByAge(persons), [
  { name: 'a', age: 1 },
  { name: 'b', age: 2 },
  { name: 'b', age: 3 },
  { name: 'c', age: 2 },
])

Added in v2.5.0 v2.5.0中添加

spanLeft   左跨距

Split an array into two parts:
将数组分成两部分:

  1. the longest initial subarray for which all elements satisfy the specified predicate
    所有元素满足指定谓词的最长初始子数组
  2. the remaining elements 剩余元素

Signature 签名

export declare function spanLeft<A, B extends A>(refinement: Refinement<A, B>): (as: ReadonlyArray<A>) => Spanned<B, A>
export declare function spanLeft<A>(predicate: Predicate<A>): <B extends A>(bs: ReadonlyArray<B>) => Spanned<B, B>
export declare function spanLeft<A>(predicate: Predicate<A>): (as: ReadonlyArray<A>) => Spanned<A, A>

Example 例子

import { spanLeft } from 'fp-ts/ReadonlyArray'

assert.deepStrictEqual(spanLeft((n: number) => n % 2 === 1)([1, 3, 2, 4, 5]), { init: [1, 3], rest: [2, 4, 5] })

Added in v2.5.0 v2.5.0中添加

splitAt   分割点

Splits a ReadonlyArray into two pieces, the first piece has max n elements.
ReadonlyArray 分成两部分,第一部分最多包含 n 元素。

Signature 签名

export declare const splitAt: (n: number) => <A>(as: readonly A[]) => readonly [readonly A[], readonly A[]]

Example 例子

import { splitAt } from 'fp-ts/ReadonlyArray'

assert.deepStrictEqual(splitAt(2)([1, 2, 3, 4, 5]), [
  [1, 2],
  [3, 4, 5],
])

Added in v2.5.0 v2.5.0中添加

tail   尾巴

Get all but the first element of an array, creating a new array, or None if the array is empty
获取数组中除第一个元素以外的所有元素,创建一个新数组,如果数组为空,则获取 None

Signature 签名

export declare const tail: <A>(as: readonly A[]) => Option<readonly A[]>

Example 例子

import { tail } from 'fp-ts/ReadonlyArray'
import { some, none } from 'fp-ts/Option'

assert.deepStrictEqual(tail([1, 2, 3]), some([2, 3]))
assert.deepStrictEqual(tail([]), none)

Added in v2.5.0 v2.5.0中添加

takeLeft   左转

Keep only a max number of elements from the start of an ReadonlyArray, creating a new ReadonlyArray.
仅保留 ReadonlyArray 开头的最大数量的元素,创建新的 ReadonlyArray

Note. n is normalized to a non negative integer.
笔记。 n 被标准化为非负整数。

Signature 签名

export declare const takeLeft: (n: number) => <A>(as: readonly A[]) => readonly A[]

Example 例子

import * as RA from 'fp-ts/ReadonlyArray'
import { pipe } from 'fp-ts/function'

const input: ReadonlyArray<number> = [1, 2, 3]
assert.deepStrictEqual(pipe(input, RA.takeLeft(2)), [1, 2])

// out of bounds
assert.strictEqual(pipe(input, RA.takeLeft(4)), input)
assert.strictEqual(pipe(input, RA.takeLeft(-1)), input)

Added in v2.5.0 v2.5.0中添加

takeLeftWhile   向左走

Calculate the longest initial subarray for which all element satisfy the specified predicate, creating a new array
计算所有元素满足指定谓词的最长初始子数组,创建一个新数组

Signature 签名

export declare function takeLeftWhile<A, B extends A>(
  refinement: Refinement<A, B>
): (as: ReadonlyArray<A>) => ReadonlyArray<B>
export declare function takeLeftWhile<A>(
  predicate: Predicate<A>
): <B extends A>(bs: ReadonlyArray<B>) => ReadonlyArray<B>
export declare function takeLeftWhile<A>(predicate: Predicate<A>): (as: ReadonlyArray<A>) => ReadonlyArray<A>

Example 例子

import { takeLeftWhile } from 'fp-ts/ReadonlyArray'

assert.deepStrictEqual(takeLeftWhile((n: number) => n % 2 === 0)([2, 4, 3, 6]), [2, 4])

Added in v2.5.0 v2.5.0中添加

takeRight   右转

Keep only a max number of elements from the end of an ReadonlyArray, creating a new ReadonlyArray.
仅保留 ReadonlyArray 末尾的最大数量的元素,创建新的 ReadonlyArray

Note. n is normalized to a non negative integer.
笔记。 n 被标准化为非负整数。

Signature 签名

export declare const takeRight: (n: number) => <A>(as: readonly A[]) => readonly A[]

Example 例子

import * as RA from 'fp-ts/ReadonlyArray'
import { pipe } from 'fp-ts/function'

const input: ReadonlyArray<number> = [1, 2, 3]
assert.deepStrictEqual(pipe(input, RA.takeRight(2)), [2, 3])

// out of bounds
assert.strictEqual(pipe(input, RA.takeRight(4)), input)
assert.strictEqual(pipe(input, RA.takeRight(-1)), input)

Added in v2.5.0 v2.5.0中添加

unfold   展开

Signature 签名

export declare const unfold: <A, B>(b: B, f: (b: B) => Option<readonly [A, B]>) => readonly A[]

Added in v2.6.6 v2.6.6 中添加

union   联盟

Creates an array of unique values, in order, from all given arrays using a Eq for equality comparisons
使用 Eq 从所有给定数组中按顺序创建唯一值数组以进行相等比较

Signature 签名

export declare function union<A>(E: Eq<A>): {
  (xs: ReadonlyArray<A>): (ys: ReadonlyArray<A>) => ReadonlyArray<A>
  (xs: ReadonlyArray<A>, ys: ReadonlyArray<A>): ReadonlyArray<A>
}

Example 例子

import { union } from 'fp-ts/ReadonlyArray'
import * as N from 'fp-ts/number'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe([1, 2], union(N.Eq)([2, 3])), [1, 2, 3])

Added in v2.5.0 v2.5.0中添加

uniq   独特的

Remove duplicates from an array, keeping the first occurrence of an element.
从数组中删除重复项,保留第一次出现的元素。

Signature 签名

export declare const uniq: <A>(E: Eq<A>) => (as: readonly A[]) => readonly A[]

Example 例子

import { uniq } from 'fp-ts/ReadonlyArray'
import * as N from 'fp-ts/number'

assert.deepStrictEqual(uniq(N.Eq)([1, 2, 1]), [1, 2])

Added in v2.5.0 v2.5.0中添加

unzip   解压

The function is reverse of zip. Takes an array of pairs and return two corresponding arrays
该功能与 zip 相反。获取一个pairs数组并返回两个对应的数组

Signature 签名

export declare const unzip: <A, B>(as: readonly (readonly [A, B])[]) => readonly [readonly A[], readonly B[]]

Example 例子

import { unzip } from 'fp-ts/ReadonlyArray'

assert.deepStrictEqual(
  unzip([
    [1, 'a'],
    [2, 'b'],
    [3, 'c'],
  ]),
  [
    [1, 2, 3],
    ['a', 'b', 'c'],
  ]
)

Added in v2.5.0 v2.5.0中添加

updateAt   更新时间

Change the element at the specified index, creating a new array, or returning None if the index is out of bounds
更改指定索引处的元素,创建新数组,或者如果索引越界则返回 None

Signature 签名

export declare const updateAt: <A>(i: number, a: A) => (as: readonly A[]) => Option<readonly A[]>

Example 例子

import { updateAt } from 'fp-ts/ReadonlyArray'
import { some, none } from 'fp-ts/Option'

assert.deepStrictEqual(updateAt(1, 1)([1, 2, 3]), some([1, 1, 3]))
assert.deepStrictEqual(updateAt(1, 1)([]), none)

Added in v2.5.0 v2.5.0中添加

zero  

Signature 签名

export declare const zero: <A>() => readonly A[]

Added in v2.7.0 v2.7.0 中添加

zip   压缩

Takes two arrays and returns an array of corresponding pairs. If one input array is short, excess elements of the longer array are discarded
接受两个数组并返回对应对的数组。如果一个输入数组很短,则较长数组中多余的元素将被丢弃

Signature 签名

export declare function zip<B>(bs: ReadonlyArray<B>): <A>(as: ReadonlyArray<A>) => ReadonlyArray<readonly [A, B]>
export declare function zip<A, B>(as: ReadonlyArray<A>, bs: ReadonlyArray<B>): ReadonlyArray<readonly [A, B]>

Example 例子

import { zip } from 'fp-ts/ReadonlyArray'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe([1, 2, 3], zip(['a', 'b', 'c', 'd'])), [
  [1, 'a'],
  [2, 'b'],
  [3, 'c'],
])

Added in v2.5.0 v2.5.0中添加

zipWith   zipWith

Apply a function to pairs of elements at the same index in two arrays, collecting the results in a new array. If one input array is short, excess elements of the longer array are discarded.
将函数应用于两个数组中相同索引处的元素对,并将结果收集到新数组中。如果一个输入数组很短,则较长数组中多余的元素将被丢弃。

Signature 签名

export declare const zipWith: <A, B, C>(fa: readonly A[], fb: readonly B[], f: (a: A, b: B) => C) => readonly C[]

Example 例子

import { zipWith } from 'fp-ts/ReadonlyArray'

assert.deepStrictEqual(
  zipWith([1, 2, 3], ['a', 'b', 'c', 'd'], (n, s) => s + n),
  ['a1', 'b2', 'c3']
)

Added in v2.5.0 v2.5.0中添加

zone of death
死亡地带

cons 缺点

Use prepend instead. 请改用 prepend

Signature 签名

export declare const cons: typeof RNEA.cons

Added in v2.5.0 v2.5.0中添加

prependToAll 前置到全部

Use prependAll instead. 请改用 prependAll

Signature 签名

export declare const prependToAll: <A>(middle: A) => (as: readonly A[]) => readonly A[]

Added in v2.9.0 v2.9.0中添加

range 范围

Use ReadonlyNonEmptyArray module instead. 请改用 ReadonlyNonEmptyArray 模块。

Signature 签名

export declare const range: (start: number, end: number) => RNEA.ReadonlyNonEmptyArray<number>

Added in v2.5.0 v2.5.0中添加

readonlyArray 只读数组

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass RA.Functor instead of RA.readonlyArray (where RA is from import RA from 'fp-ts/ReadonlyArray')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 RA.Functor 而不是 RA.readonlyArray (其中 RA 来自 import RA from 'fp-ts/ReadonlyArray'

Signature 签名

export declare const readonlyArray: FunctorWithIndex1<'ReadonlyArray', number> &
  Monad1<'ReadonlyArray'> &
  Unfoldable1<'ReadonlyArray'> &
  Alternative1<'ReadonlyArray'> &
  Extend1<'ReadonlyArray'> &
  FilterableWithIndex1<'ReadonlyArray', number> &
  FoldableWithIndex1<'ReadonlyArray', number> &
  TraversableWithIndex1<'ReadonlyArray', number> &
  Witherable1<'ReadonlyArray'>

Added in v2.5.0 v2.5.0中添加

snoc 斯诺克

Use append instead. 请改用 append

Signature 签名

export declare const snoc: <A>(init: readonly A[], end: A) => RNEA.ReadonlyNonEmptyArray<A>

Added in v2.5.0 v2.5.0中添加

ReadonlyMap overview  只读地图概述

Added in v2.5.0 v2.5.0中添加


Table of contents
目录


constructors  构造函数

fromFoldable   来自可折叠

Create a map from a foldable collection of key/value pairs, using the specified Magma to combine values for duplicate keys.
从可折叠的键/值对集合创建映射,使用指定的 Magma 来组合重复键的值。

Signature 签名

export declare function fromFoldable<F extends URIS3, K, A>(
  E: Eq<K>,
  M: Magma<A>,
  F: Foldable3<F>
): <R, E>(fka: Kind3<F, R, E, readonly [K, A]>) => ReadonlyMap<K, A>
export declare function fromFoldable<F extends URIS2, K, A>(
  E: Eq<K>,
  M: Magma<A>,
  F: Foldable2<F>
): <E>(fka: Kind2<F, E, readonly [K, A]>) => ReadonlyMap<K, A>
export declare function fromFoldable<F extends URIS, K, A>(
  E: Eq<K>,
  M: Magma<A>,
  F: Foldable1<F>
): (fka: Kind<F, readonly [K, A]>) => ReadonlyMap<K, A>
export declare function fromFoldable<F, K, A>(
  E: Eq<K>,
  M: Magma<A>,
  F: Foldable<F>
): (fka: HKT<F, readonly [K, A]>) => ReadonlyMap<K, A>

Added in v2.5.0 v2.5.0中添加

singleton   单例

Create a map with one key/value pair
使用一个键/值对创建一个映射

Signature 签名

export declare const singleton: <K, A>(k: K, a: A) => ReadonlyMap<K, A>

Added in v2.5.0 v2.5.0中添加

conversions   转换

fromMap   来自地图

Signature 签名

export declare const fromMap: <K, A>(m: Map<K, A>) => ReadonlyMap<K, A>

Added in v2.5.0 v2.5.0中添加

toMap   到地图

Signature 签名

export declare function toMap<K, A>(m: ReadonlyMap<K, A>): Map<K, A>

Added in v2.5.0 v2.5.0中添加

toReadonlyArray   到只读数组

Get a sorted ReadonlyArray of the key/value pairs contained in a ReadonlyMap.
获取 ReadonlyMap 中包含的键/值对的排序 ReadonlyArray

Signature 签名

export declare const toReadonlyArray: <K>(O: Ord<K>) => <A>(m: ReadonlyMap<K, A>) => readonly (readonly [K, A])[]

Added in v2.5.0 v2.5.0中添加

toUnfoldable   至可展开

Unfolds a map into a list of key/value pairs
将映射展开为键/值对列表

Signature 签名

export declare function toUnfoldable<K, F extends URIS>(
  ord: Ord<K>,
  U: Unfoldable1<F>
): <A>(d: ReadonlyMap<K, A>) => Kind<F, readonly [K, A]>
export declare function toUnfoldable<K, F>(
  ord: Ord<K>,
  U: Unfoldable<F>
): <A>(d: ReadonlyMap<K, A>) => HKT<F, readonly [K, A]>

Added in v2.5.0 v2.5.0中添加

filtering   过滤

compact   袖珍的

Signature 签名

export declare const compact: <K, A>(fa: ReadonlyMap<K, O.Option<A>>) => ReadonlyMap<K, A>

Added in v2.5.0 v2.5.0中添加

filter   筛选

Signature 签名

export declare const filter: {
  <A, B extends A>(refinement: Refinement<A, B>): <K>(fa: ReadonlyMap<K, A>) => ReadonlyMap<K, B>
  <A>(predicate: Predicate<A>): <K, B extends A>(fb: ReadonlyMap<K, B>) => ReadonlyMap<K, B>
  <A>(predicate: Predicate<A>): <K>(fa: ReadonlyMap<K, A>) => ReadonlyMap<K, A>
}

Added in v2.5.0 v2.5.0中添加

filterMap   过滤映射

Signature 签名

export declare const filterMap: <A, B>(f: (a: A) => O.Option<B>) => <K>(fa: ReadonlyMap<K, A>) => ReadonlyMap<K, B>

Added in v2.5.0 v2.5.0中添加

getFilterableWithIndex   获取可过滤的索引

Signature 签名

export declare function getFilterableWithIndex<K = never>(): FilterableWithIndex2C<URI, K, K>

Added in v2.5.0 v2.5.0中添加

getWitherable   变得枯萎

Signature 签名

export declare function getWitherable<K>(O: Ord<K>): Witherable2C<URI, K> & TraversableWithIndex2C<URI, K, K>

Added in v2.5.0 v2.5.0中添加

partition   分割

Signature 签名

export declare const partition: {
  <A, B extends A>(refinement: Refinement<A, B>): <K>(
    fa: ReadonlyMap<K, A>
  ) => Separated<ReadonlyMap<K, A>, ReadonlyMap<K, B>>
  <A>(predicate: Predicate<A>): <K, B extends A>(
    fb: ReadonlyMap<K, B>
  ) => Separated<ReadonlyMap<K, B>, ReadonlyMap<K, B>>
  <A>(predicate: Predicate<A>): <K>(fa: ReadonlyMap<K, A>) => Separated<ReadonlyMap<K, A>, ReadonlyMap<K, A>>
}

Added in v2.5.0 v2.5.0中添加

partitionMap   分区图

Signature 签名

export declare const partitionMap: <A, B, C>(
  f: (a: A) => Either<B, C>
) => <K>(fa: ReadonlyMap<K, A>) => Separated<ReadonlyMap<K, B>, ReadonlyMap<K, C>>

Added in v2.5.0 v2.5.0中添加

separate   分离

Signature 签名

export declare const separate: <K, A, B>(
  fa: ReadonlyMap<K, Either<A, B>>
) => Separated<ReadonlyMap<K, A>, ReadonlyMap<K, B>>

Added in v2.5.0 v2.5.0中添加

folding   折叠式的

foldMap   折叠图

Signature 签名

export declare const foldMap: <K>(O: Ord<K>) => <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (m: ReadonlyMap<K, A>) => M

Added in v2.11.0 v2.11.0 中添加

foldMapWithIndex   带索引的折叠地图

Signature 签名

export declare const foldMapWithIndex: <K>(
  O: Ord<K>
) => <M>(M: Monoid<M>) => <A>(f: (k: K, a: A) => M) => (m: ReadonlyMap<K, A>) => M

Added in v2.11.0 v2.11.0 中添加

getFoldable   获取可折叠的

Signature 签名

export declare const getFoldable: <K>(O: Ord<K>) => Foldable2C<'ReadonlyMap', K>

Added in v2.10.0 v2.10.0 中添加

getFoldableWithIndex   获取FoldableWithIndex

Signature 签名

export declare const getFoldableWithIndex: <K>(O: Ord<K>) => FoldableWithIndex2C<'ReadonlyMap', K, K>

Added in v2.10.0 v2.10.0 中添加

reduce   减少

Signature 签名

export declare const reduce: <K>(O: Ord<K>) => <B, A>(b: B, f: (b: B, a: A) => B) => (m: ReadonlyMap<K, A>) => B

Added in v2.11.0 v2.11.0 中添加

reduceRight   减少右

Signature 签名

export declare const reduceRight: <K>(O: Ord<K>) => <B, A>(b: B, f: (a: A, b: B) => B) => (m: ReadonlyMap<K, A>) => B

Added in v2.11.0 v2.11.0 中添加

reduceRightWithIndex   减少右索引

Signature 签名

export declare const reduceRightWithIndex: <K>(
  O: Ord<K>
) => <B, A>(b: B, f: (k: K, a: A, b: B) => B) => (m: ReadonlyMap<K, A>) => B

Added in v2.11.0 v2.11.0 中添加

reduceWithIndex  减少索引

Signature 签名

export declare const reduceWithIndex: <K>(
  O: Ord<K>
) => <B, A>(b: B, f: (k: K, b: B, a: A) => B) => (m: ReadonlyMap<K, A>) => B

Added in v2.11.0 v2.11.0 中添加

instances   实例

Compactable   紧凑型

Signature 签名

export declare const Compactable: Compactable2<'ReadonlyMap'>

Added in v2.7.0 v2.7.0 中添加

Filterable   可过滤

Signature 签名

export declare const Filterable: Filterable2<'ReadonlyMap'>

Added in v2.7.0 v2.7.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor2<'ReadonlyMap'>

Added in v2.7.0 v2.7.0 中添加

getDifferenceMagma   获取差异岩浆

Signature 签名

export declare const getDifferenceMagma: <K>(E: Eq<K>) => <A>() => Magma<ReadonlyMap<K, A>>

Added in v2.11.0 v2.11.0 中添加

getEq   得到方程

Signature 签名

export declare function getEq<K, A>(SK: Eq<K>, SA: Eq<A>): Eq<ReadonlyMap<K, A>>

Added in v2.5.0 v2.5.0中添加

getFunctorWithIndex   获取带有索引的函子

Signature 签名

export declare const getFunctorWithIndex: <K = never>() => FunctorWithIndex2C<'ReadonlyMap', K, K>

Added in v2.10.0 v2.10.0 中添加

getIntersectionSemigroup
获取交集半群

Signature 签名

export declare const getIntersectionSemigroup: <K, A>(E: Eq<K>, S: Semigroup<A>) => Semigroup<ReadonlyMap<K, A>>

Added in v2.11.0 v2.11.0 中添加

getMonoid   获取Monoid

Gets Monoid instance for Maps given Semigroup instance for their values
获取 Maps 的 Monoid 实例,为其值指定 Semigroup 实例

Signature 签名

export declare function getMonoid<K, A>(SK: Eq<K>, SA: Semigroup<A>): Monoid<ReadonlyMap<K, A>>

Added in v2.5.0 v2.5.0中添加

getShow   获取显示

Signature 签名

export declare function getShow<K, A>(SK: Show<K>, SA: Show<A>): Show<ReadonlyMap<K, A>>

Added in v2.5.0 v2.5.0中添加

getUnionMonoid  获取UnionMonoid

Signature 签名

export declare const getUnionMonoid: <K, A>(E: Eq<K>, S: Semigroup<A>) => Monoid<ReadonlyMap<K, A>>

Added in v2.11.0 v2.11.0 中添加

getUnionSemigroup   获取UnionSemigroup

Signature 签名

export declare const getUnionSemigroup: <K, A>(E: Eq<K>, S: Semigroup<A>) => Semigroup<ReadonlyMap<K, A>>

Added in v2.11.0 v2.11.0 中添加

mapping   映射

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <E, B>(fab: ReadonlyMap<E, (a: A) => B>) => ReadonlyMap<E, B>

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => <K>(fa: ReadonlyMap<K, A>) => ReadonlyMap<K, B>

Added in v2.5.0 v2.5.0中添加

mapWithIndex   带索引的映射

Signature 签名

export declare const mapWithIndex: <K, A, B>(f: (k: K, a: A) => B) => (fa: ReadonlyMap<K, A>) => ReadonlyMap<K, B>

Added in v2.7.1 v2.7.1 中添加

traversing   穿越

getTraversable   获取可遍历的

Signature 签名

export declare const getTraversable: <K>(O: Ord<K>) => Traversable2C<'ReadonlyMap', K>

Added in v2.10.0 v2.10.0 中添加

getTraversableWithIndex
getTraversableWithIndex

Signature 签名

export declare const getTraversableWithIndex: <K>(O: Ord<K>) => TraversableWithIndex2C<'ReadonlyMap', K, K>

Added in v2.10.0 v2.10.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'ReadonlyMap'

Added in v2.5.0 v2.5.0中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.5.0 v2.5.0中添加

utils   实用程序

collect   收集

Signature 签名

export declare function collect<K>(
  O: Ord<K>
): <A, B>(f: (k: K, a: A) => B) => (m: ReadonlyMap<K, A>) => ReadonlyArray<B>

Added in v2.5.0 v2.5.0中添加

deleteAt   删除处

Delete a key and value from a map
从映射中删除键和值

Signature 签名

export declare const deleteAt: <K>(E: Eq<K>) => (k: K) => <A>(m: ReadonlyMap<K, A>) => ReadonlyMap<K, A>

Added in v2.5.0 v2.5.0中添加

difference   不同之处

Signature 签名

export declare const difference: <K>(
  E: Eq<K>
) => <A>(_second: ReadonlyMap<K, A>) => (first: ReadonlyMap<K, A>) => ReadonlyMap<K, A>

Added in v2.11.0 v2.11.0 中添加

elem   埃莱姆

Test whether or not a value is a member of a map
测试某个值是否是映射的成员

Signature 签名

export declare function elem<A>(E: Eq<A>): {
  (a: A): <K>(m: ReadonlyMap<K, A>) => boolean
  <K>(a: A, m: ReadonlyMap<K, A>): boolean
}

Added in v2.5.0 v2.5.0中添加

empty   空的

Signature 签名

export declare const empty: ReadonlyMap<never, never>

Added in v2.5.0 v2.5.0中添加

filterMapWithIndex   带索引的过滤映射

Signature 签名

export declare const filterMapWithIndex: <K, A, B>(
  f: (k: K, a: A) => O.Option<B>
) => (fa: ReadonlyMap<K, A>) => ReadonlyMap<K, B>

Added in v2.10.0 v2.10.0 中添加

filterWithIndex   带索引的过滤器

Signature 签名

export declare function filterWithIndex<K, A, B extends A>(
  predicateWithIndex: (k: K, a: A) => a is B
): (m: ReadonlyMap<K, A>) => ReadonlyMap<K, B>
export declare function filterWithIndex<K, A>(
  predicateWithIndex: (k: K, a: A) => boolean
): <B extends A>(m: ReadonlyMap<K, B>) => ReadonlyMap<K, B>
export declare function filterWithIndex<K, A>(
  predicateWithIndex: (k: K, a: A) => boolean
): (m: ReadonlyMap<K, A>) => ReadonlyMap<K, A>

Added in v2.10.0 v2.10.0 中添加

intersection   路口

Signature 签名

export declare const intersection: <K, A>(
  E: Eq<K>,
  M: Magma<A>
) => (second: ReadonlyMap<K, A>) => (first: ReadonlyMap<K, A>) => ReadonlyMap<K, A>

Added in v2.11.0 v2.11.0 中添加

isEmpty   是空的

Test whether or not a map is empty
测试地图是否为空

Signature 签名

export declare const isEmpty: <K, A>(m: ReadonlyMap<K, A>) => boolean

Added in v2.5.0 v2.5.0中添加

isSubmap   是子图

Test whether or not one Map contains all of the keys and values contained in another Map
测试一个 Map 是否包含另一个 Map 中包含的所有键和值

Signature 签名

export declare function isSubmap<K, A>(
  SK: Eq<K>,
  SA: Eq<A>
): {
  (that: ReadonlyMap<K, A>): (me: ReadonlyMap<K, A>) => boolean
  (me: ReadonlyMap<K, A>, that: ReadonlyMap<K, A>): boolean
}

Added in v2.5.0 v2.5.0中添加

keys  

Get a sorted ReadonlyArray of the keys contained in a ReadonlyMap.
获取 ReadonlyMap 中包含的键的排序 ReadonlyArray

Signature 签名

export declare const keys: <K>(O: Ord<K>) => <A>(m: ReadonlyMap<K, A>) => readonly K[]

Added in v2.5.0 v2.5.0中添加

lookup   抬头

Lookup the value for a key in a Map.
Map 中查找键的值。

Signature 签名

export declare function lookup<K>(E: Eq<K>): {
  (k: K): <A>(m: ReadonlyMap<K, A>) => Option<A>
  <A>(k: K, m: ReadonlyMap<K, A>): Option<A>
}

Added in v2.5.0 v2.5.0中添加

lookupWithKey   关键字查找

Lookup the value for a key in a Map. If the result is a Some, the existing key is also returned.
Map 中查找键的值。如果结果是 Some ,则还会返回现有的密钥。

Signature 签名

export declare function lookupWithKey<K>(E: Eq<K>): {
  (k: K): <A>(m: ReadonlyMap<K, A>) => Option<readonly [K, A]>
  <A>(k: K, m: ReadonlyMap<K, A>): Option<readonly [K, A]>
}

Added in v2.5.0 v2.5.0中添加

member   成员

Test whether or not a key exists in a map
测试映射中是否存在某个键

Signature 签名

export declare function member<K>(E: Eq<K>): {
  (k: K): <A>(m: ReadonlyMap<K, A>) => boolean
  <A>(k: K, m: ReadonlyMap<K, A>): boolean
}

Added in v2.5.0 v2.5.0中添加

modifyAt   修改处

Signature 签名

export declare const modifyAt: <K>(
  E: Eq<K>
) => <A>(k: K, f: (a: A) => A) => (m: ReadonlyMap<K, A>) => O.Option<ReadonlyMap<K, A>>

Added in v2.5.0 v2.5.0中添加

partitionMapWithIndex   带索引的分区映射

Signature 签名

export declare const partitionMapWithIndex: <K, A, B, C>(
  f: (k: K, a: A) => Either<B, C>
) => (fa: ReadonlyMap<K, A>) => Separated<ReadonlyMap<K, B>, ReadonlyMap<K, C>>

Added in v2.10.0 v2.10.0 中添加

partitionWithIndex   带索引分区

Signature 签名

export declare function partitionWithIndex<K, A, B extends A>(
  predicateWithIndex: (k: K, a: A) => a is B
): (m: ReadonlyMap<K, A>) => Separated<ReadonlyMap<K, A>, ReadonlyMap<K, B>>
export declare function partitionWithIndex<K, A>(
  predicateWithIndex: (k: K, a: A) => boolean
): <B extends A>(m: ReadonlyMap<K, B>) => Separated<ReadonlyMap<K, B>, ReadonlyMap<K, B>>
export declare function partitionWithIndex<K, A>(
  predicateWithIndex: (k: K, a: A) => boolean
): (m: ReadonlyMap<K, A>) => Separated<ReadonlyMap<K, A>, ReadonlyMap<K, A>>

Added in v2.10.0 v2.10.0 中添加

pop   流行音乐

Delete a key and value from a map, returning the value as well as the subsequent map
从映射中删除键和值,返回该值以及后续映射

Signature 签名

export declare function pop<K>(E: Eq<K>): (k: K) => <A>(m: ReadonlyMap<K, A>) => Option<readonly [A, ReadonlyMap<K, A>]>

Added in v2.5.0 v2.5.0中添加

size   尺寸

Calculate the number of key/value pairs in a map
计算映射中键/值对的数量

Signature 签名

export declare const size: <K, A>(m: ReadonlyMap<K, A>) => number

Added in v2.5.0 v2.5.0中添加

union   联盟

Signature 签名

export declare const union: <K, A>(
  E: Eq<K>,
  M: Magma<A>
) => (second: ReadonlyMap<K, A>) => (first: ReadonlyMap<K, A>) => ReadonlyMap<K, A>

Added in v2.11.0 v2.11.0 中添加

updateAt   更新时间

Signature 签名

export declare const updateAt: <K>(E: Eq<K>) => <A>(k: K, a: A) => (m: ReadonlyMap<K, A>) => O.Option<ReadonlyMap<K, A>>

Added in v2.5.0 v2.5.0中添加

upsertAt   更新插入

Insert or replace a key/value pair in a ReadonlyMap.
ReadonlyMap 中插入或替换键/值对。

Signature 签名

export declare const upsertAt: <K>(E: Eq<K>) => <A>(k: K, a: A) => (m: ReadonlyMap<K, A>) => ReadonlyMap<K, A>

Added in v2.10.0 v2.10.0 中添加

values   价值观

Get a sorted ReadonlyArray of the values contained in a ReadonlyMap.
获取 ReadonlyMap 中包含的值的排序 ReadonlyArray

Signature 签名

export declare const values: <A>(O: Ord<A>) => <K>(m: ReadonlyMap<K, A>) => readonly A[]

Added in v2.5.0 v2.5.0中添加

zone of death
死亡地带

insertAt 插入位置

Use upsertAt instead. 请改用 upsertAt

Signature 签名

export declare const insertAt: <K>(E: Eq<K>) => <A>(k: K, a: A) => (m: ReadonlyMap<K, A>) => ReadonlyMap<K, A>

Added in v2.5.0 v2.5.0中添加

readonlyMap 只读地图

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass RM.Functor instead of RM.readonlyMap (where RM is from import RM from 'fp-ts/ReadonlyMap')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 RM.Functor 而不是 RM.readonlyMap (其中 RM 来自 import RM from 'fp-ts/ReadonlyMap'

Signature 签名

export declare const readonlyMap: Filterable2<'ReadonlyMap'>

Added in v2.5.0 v2.5.0中添加

ReadonlyNonEmptyArray overview
ReadonlyNonEmptyArray 概述

Data structure which represents non-empty readonly arrays.
表示非空只读数组的数据结构。

export type ReadonlyNonEmptyArray<A> = ReadonlyArray<A> & {
  readonly 0: A
}

Note that you don’t need any conversion, a ReadonlyNonEmptyArray is a ReadonlyArray, so all ReadonlyArray’s APIs can be used with a ReadonlyNonEmptyArray without further ado.
请注意,您不需要任何转换, ReadonlyNonEmptyArray 就是 ReadonlyArray ,因此所有 ReadonlyArray 的 API 都可以与 ReadonlyNonEmptyArray 一起使用,无需多说。

Added in v2.5.0 v2.5.0中添加


Table of contents
目录


Comonad   科莫纳德

extract   提炼

Signature 签名

export declare const extract: <A>(wa: ReadonlyNonEmptyArray<A>) => A

Added in v2.6.3 v2.6.3 中添加

constructors  构造函数

makeBy  制造者

Return a ReadonlyNonEmptyArray of length n with element i initialized with f(i).
返回长度为 nReadonlyNonEmptyArray ,其中元素 if(i) 初始化。

Note. n is normalized to a natural number.
笔记。 n 标准化为自然数。

Signature 签名

export declare const makeBy: <A>(f: (i: number) => A) => (n: number) => ReadonlyNonEmptyArray<A>

Example 例子

import { makeBy } from 'fp-ts/ReadonlyNonEmptyArray'
import { pipe } from 'fp-ts/function'

const double = (n: number): number => n * 2
assert.deepStrictEqual(pipe(5, makeBy(double)), [0, 2, 4, 6, 8])

Added in v2.11.0 v2.11.0 中添加

of  

Signature 签名

export declare const of: <A>(a: A) => ReadonlyNonEmptyArray<A>

Added in v2.5.0 v2.5.0中添加

range   范围

Create a ReadonlyNonEmptyArray containing a range of integers, including both endpoints.
创建一个包含一系列整数的 ReadonlyNonEmptyArray ,包括两个端点。

Signature 签名

export declare const range: (start: number, end: number) => ReadonlyNonEmptyArray<number>

Example 例子

import { range } from 'fp-ts/ReadonlyNonEmptyArray'

assert.deepStrictEqual(range(1, 5), [1, 2, 3, 4, 5])

Added in v2.11.0 v2.11.0 中添加

replicate   复制

Create a ReadonlyNonEmptyArray containing a value repeated the specified number of times.
创建一个包含重复指定次数的值的 ReadonlyNonEmptyArray

Note. n is normalized to a natural number.
笔记。 n 标准化为自然数。

Signature 签名

export declare const replicate: <A>(a: A) => (n: number) => ReadonlyNonEmptyArray<A>

Example 例子

import { replicate } from 'fp-ts/ReadonlyNonEmptyArray'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe(3, replicate('a')), ['a', 'a', 'a'])

Added in v2.11.0 v2.11.0 中添加

conversions   转换

fromArray   来自数组

Signature 签名

export declare const fromArray: <A>(as: A[]) => Option<ReadonlyNonEmptyArray<A>>

Added in v2.5.0 v2.5.0中添加

fromReadonlyArray   来自只读数组

Return a ReadonlyNonEmptyArray from a ReadonlyArray returning none if the input is empty.
如果输入为空,则从返回 noneReadonlyArray 返回 ReadonlyNonEmptyArray

Signature 签名

export declare const fromReadonlyArray: <A>(as: readonly A[]) => Option<ReadonlyNonEmptyArray<A>>

Added in v2.5.0 v2.5.0中添加

do notation   做记号

Do  

Signature 签名

export declare const Do: ReadonlyNonEmptyArray<{}>

Added in v2.9.0 v2.9.0中添加

apS   apS

Signature 签名

export declare const apS: <N, A, B>(
  name: Exclude<N, keyof A>,
  fb: ReadonlyNonEmptyArray<B>
) => (
  fa: ReadonlyNonEmptyArray<A>
) => ReadonlyNonEmptyArray<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bind   绑定

Signature 签名

export declare const bind: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => ReadonlyNonEmptyArray<B>
) => (
  ma: ReadonlyNonEmptyArray<A>
) => ReadonlyNonEmptyArray<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bindTo   绑定到

Signature 签名

export declare const bindTo: <N>(
  name: N
) => <A>(fa: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<{ readonly [K in N]: A }>

Added in v2.8.0 v2.8.0 中添加

let  

Signature 签名

export declare const let: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => (
  fa: ReadonlyNonEmptyArray<A>
) => ReadonlyNonEmptyArray<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.13.0 v2.13.0 中添加

error handling   错误处理

alt   替代

Identifies an associative operation on a type constructor. It is similar to Semigroup, except that it applies to types of kind * -> *.
标识类型构造函数上的关联操作。它与 Semigroup 类似,但它适用于 * -> * 类型。

In case of ReadonlyNonEmptyArray concatenates the inputs into a single array.
如果是 ReadonlyNonEmptyArray ,则将输入连接到单个数组中。

Signature 签名

export declare const alt: <A>(
  that: LazyArg<ReadonlyNonEmptyArray<A>>
) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>

Example 例子

import * as RNEA from 'fp-ts/ReadonlyNonEmptyArray'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(
  pipe(
    [1, 2, 3],
    RNEA.alt(() => [4, 5])
  ),
  [1, 2, 3, 4, 5]
)

Added in v2.6.2 v2.6.2 中添加

altW   替代W

Less strict version of alt.
alt 的不太严格版本。

The W suffix (short for Widening) means that the return types will be merged.
W 后缀(Widening 的缩写)意味着返回类型将被合并。

Signature 签名

export declare const altW: <B>(
  that: LazyArg<ReadonlyNonEmptyArray<B>>
) => <A>(as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<B | A>

Example 例子

import * as RNEA from 'fp-ts/ReadonlyNonEmptyArray'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(
  pipe(
    [1, 2, 3] as RNEA.ReadonlyNonEmptyArray<number>,
    RNEA.altW(() => ['a', 'b'])
  ),
  [1, 2, 3, 'a', 'b']
)

Added in v2.9.0 v2.9.0中添加

folding   折叠式的

foldMap   折叠图

Note. The constraint is relaxed: a Semigroup instead of a Monoid.
笔记。放松了约束: Semigroup 而不是 Monoid

Signature 签名

export declare const foldMap: <S>(S: Se.Semigroup<S>) => <A>(f: (a: A) => S) => (as: ReadonlyNonEmptyArray<A>) => S

Added in v2.5.0 v2.5.0中添加

foldMapWithIndex   带索引的折叠地图

Note. The constraint is relaxed: a Semigroup instead of a Monoid.
笔记。放松了约束: Semigroup 而不是 Monoid

Signature 签名

export declare const foldMapWithIndex: <S>(
  S: Se.Semigroup<S>
) => <A>(f: (i: number, a: A) => S) => (as: ReadonlyNonEmptyArray<A>) => S

Added in v2.5.0 v2.5.0中添加

reduce   减少

Signature 签名

export declare const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (as: ReadonlyNonEmptyArray<A>) => B

Added in v2.5.0 v2.5.0中添加

reduceRight   减少右

Signature 签名

export declare const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (as: ReadonlyNonEmptyArray<A>) => B

Added in v2.5.0 v2.5.0中添加

reduceRightWithIndex   减少右索引

Signature 签名

export declare const reduceRightWithIndex: <A, B>(
  b: B,
  f: (i: number, a: A, b: B) => B
) => (as: ReadonlyNonEmptyArray<A>) => B

Added in v2.5.0 v2.5.0中添加

reduceWithIndex  减少索引

Signature 签名

export declare const reduceWithIndex: <A, B>(
  b: B,
  f: (i: number, b: B, a: A) => B
) => (as: ReadonlyNonEmptyArray<A>) => B

Added in v2.5.0 v2.5.0中添加

instances   实例

Alt   替代

Signature 签名

export declare const Alt: Alt1<'ReadonlyNonEmptyArray'>

Added in v2.7.0 v2.7.0 中添加

Applicative   适用性

Signature 签名

export declare const Applicative: Applicative1<'ReadonlyNonEmptyArray'>

Added in v2.7.0 v2.7.0 中添加

Apply   申请

Signature 签名

export declare const Apply: Apply1<'ReadonlyNonEmptyArray'>

Added in v2.10.0 v2.10.0 中添加

Chain  

Signature 签名

export declare const Chain: Chain1<'ReadonlyNonEmptyArray'>

Added in v2.10.0 v2.10.0 中添加

Comonad   科莫纳德

Signature 签名

export declare const Comonad: Comonad1<'ReadonlyNonEmptyArray'>

Added in v2.7.0 v2.7.0 中添加

Foldable   折叠式

Signature 签名

export declare const Foldable: Foldable1<'ReadonlyNonEmptyArray'>

Added in v2.7.0 v2.7.0 中添加

FoldableWithIndex   可折叠带索引

Signature 签名

export declare const FoldableWithIndex: FoldableWithIndex1<'ReadonlyNonEmptyArray', number>

Added in v2.7.0 v2.7.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor1<'ReadonlyNonEmptyArray'>

Added in v2.7.0 v2.7.0 中添加

FunctorWithIndex   带索引的函子

Signature 签名

export declare const FunctorWithIndex: FunctorWithIndex1<'ReadonlyNonEmptyArray', number>

Added in v2.7.0 v2.7.0 中添加

Monad   单子

Signature 签名

export declare const Monad: Monad1<'ReadonlyNonEmptyArray'>

Added in v2.7.0 v2.7.0 中添加

Pointed  

Signature 签名

export declare const Pointed: Pointed1<'ReadonlyNonEmptyArray'>

Added in v2.10.0 v2.10.0 中添加

Traversable   可穿越

Signature 签名

export declare const Traversable: Traversable1<'ReadonlyNonEmptyArray'>

Added in v2.7.0 v2.7.0 中添加

TraversableWithIndex   可遍历索引

Signature 签名

export declare const TraversableWithIndex: TraversableWithIndex1<'ReadonlyNonEmptyArray', number>

Added in v2.7.0 v2.7.0 中添加

getEq   得到方程

Signature 签名

export declare const getEq: <A>(E: Eq<A>) => Eq<ReadonlyNonEmptyArray<A>>

Example 例子

import { getEq } from 'fp-ts/ReadonlyNonEmptyArray'
import * as N from 'fp-ts/number'

const E = getEq(N.Eq)
assert.strictEqual(E.equals([1, 2], [1, 2]), true)
assert.strictEqual(E.equals([1, 2], [1, 3]), false)

Added in v2.5.0 v2.5.0中添加

getSemigroup   获取半群

Builds a Semigroup instance for ReadonlyNonEmptyArray
ReadonlyNonEmptyArray 构建一个 Semigroup 实例

Signature 签名

export declare const getSemigroup: <A = never>() => Se.Semigroup<ReadonlyNonEmptyArray<A>>

Added in v2.5.0 v2.5.0中添加

getShow   获取显示

Signature 签名

export declare const getShow: <A>(S: Show<A>) => Show<ReadonlyNonEmptyArray<A>>

Added in v2.5.0 v2.5.0中添加

legacy   遗产

chain  

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chain: <A, B>(
  f: (a: A) => ReadonlyNonEmptyArray<B>
) => (ma: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<B>

Added in v2.5.0 v2.5.0中添加

mapping   映射

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <B>(fab: ReadonlyNonEmptyArray<(a: A) => B>) => ReadonlyNonEmptyArray<B>

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<B>

Added in v2.5.0 v2.5.0中添加

mapWithIndex   带索引的映射

Signature 签名

export declare const mapWithIndex: <A, B>(
  f: (i: number, a: A) => B
) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<B>

Added in v2.5.0 v2.5.0中添加

model   模型

ReadonlyNonEmptyArray (type alias)
ReadonlyNonEmptyArray(类型别名)

Signature 签名

export type ReadonlyNonEmptyArray<A> = ReadonlyArray<A> & {
  readonly 0: A
}

Added in v2.5.0 v2.5.0中添加

pattern matching   模式匹配

matchLeft   左匹配

Break a ReadonlyArray into its first element and remaining elements.
ReadonlyArray 分解为其第一个元素和其余元素。

Signature 签名

export declare const matchLeft: <A, B>(f: (head: A, tail: readonly A[]) => B) => (as: ReadonlyNonEmptyArray<A>) => B

Added in v2.11.0 v2.11.0 中添加

matchRight   右匹配

Break a ReadonlyArray into its initial elements and the last element.
ReadonlyArray 分解为其初始元素和最后一个元素。

Signature 签名

export declare const matchRight: <A, B>(f: (init: readonly A[], last: A) => B) => (as: ReadonlyNonEmptyArray<A>) => B

Added in v2.11.0 v2.11.0 中添加

sequencing   测序

chainFirst   链优先

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const chainFirst: <A, B>(
  f: (a: A) => ReadonlyNonEmptyArray<B>
) => (first: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>

Example 例子

import * as RA from 'fp-ts/ReadonlyArray'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(
  pipe(
    [1, 2, 3],
    RA.chainFirst(() => ['a', 'b'])
  ),
  [1, 1, 2, 2, 3, 3]
)

Added in v2.5.0 v2.5.0中添加

chainWithIndex   带索引的链

Signature 签名

export declare const chainWithIndex: <A, B>(
  f: (i: number, a: A) => ReadonlyNonEmptyArray<B>
) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<B>

Added in v2.10.0 v2.10.0 中添加

flatMap   平面地图

Signature 签名

export declare const flatMap: {
  <A, B>(f: (a: A, i: number) => ReadonlyNonEmptyArray<B>): (ma: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<B>
  <A, B>(ma: ReadonlyNonEmptyArray<A>, f: (a: A, i: number) => ReadonlyNonEmptyArray<B>): ReadonlyNonEmptyArray<B>
}

Example 例子

import * as RNEA from 'fp-ts/ReadonlyNonEmptyArray'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(
  pipe(
    [1, 2, 3],
    RNEA.flatMap((n) => [`a${n}`, `b${n}`])
  ),
  ['a1', 'b1', 'a2', 'b2', 'a3', 'b3']
)

Added in v2.14.0 v2.14.0 中添加

flatten   压扁

Signature 签名

export declare const flatten: <A>(mma: ReadonlyNonEmptyArray<ReadonlyNonEmptyArray<A>>) => ReadonlyNonEmptyArray<A>

Added in v2.5.0 v2.5.0中添加

traverseWithIndex   索引遍历

Signature 签名

export declare const traverseWithIndex: PipeableTraverseWithIndex1<'ReadonlyNonEmptyArray', number>

Added in v2.6.3 v2.6.3 中添加

traversing   穿越

sequence   顺序

Signature 签名

export declare const sequence: Sequence1<'ReadonlyNonEmptyArray'>

Added in v2.6.3 v2.6.3 中添加

traverse   遍历

Signature 签名

export declare const traverse: PipeableTraverse1<'ReadonlyNonEmptyArray'>

Added in v2.6.3 v2.6.3 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'ReadonlyNonEmptyArray'

Added in v2.5.0 v2.5.0中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.5.0 v2.5.0中添加

utils   实用程序

ap   美联社

Signature 签名

export declare const ap: <A>(
  as: ReadonlyNonEmptyArray<A>
) => <B>(fab: ReadonlyNonEmptyArray<(a: A) => B>) => ReadonlyNonEmptyArray<B>

Added in v2.5.0 v2.5.0中添加

apFirst   应用程序第一

Combine two effectful actions, keeping only the result of the first.
结合两个有效的操作,仅保留第一个操作的结果。

Signature 签名

export declare const apFirst: <B>(
  second: ReadonlyNonEmptyArray<B>
) => <A>(first: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>

Added in v2.5.0 v2.5.0中添加

apSecond   ap秒

Combine two effectful actions, keeping only the result of the second.
结合两个有效的操作,只保留第二个的结果。

Signature 签名

export declare const apSecond: <B>(
  second: ReadonlyNonEmptyArray<B>
) => <A>(first: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<B>

Added in v2.5.0 v2.5.0中添加

chop  

A useful recursion pattern for processing a ReadonlyNonEmptyArray to produce a new ReadonlyNonEmptyArray, often used for “chopping” up the input ReadonlyNonEmptyArray. Typically chop is called with some function that will consume an initial prefix of the ReadonlyNonEmptyArray and produce a value and the tail of the ReadonlyNonEmptyArray.
一种有用的递归模式,用于处理 ReadonlyNonEmptyArray 以生成新的 ReadonlyNonEmptyArray ,通常用于“切碎”输入 ReadonlyNonEmptyArray 。通常, chop 是通过某个函数调用的,该函数将消耗 ReadonlyNonEmptyArray 的初始前缀并生成一个值和 ReadonlyNonEmptyArray 的尾部。

Signature 签名

export declare const chop: <A, B>(
  f: (as: ReadonlyNonEmptyArray<A>) => readonly [B, readonly A[]]
) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<B>

Added in v2.10.0 v2.10.0 中添加

chunksOf   大块

Splits a ReadonlyNonEmptyArray into length-n pieces. The last piece will be shorter if n does not evenly divide the length of the ReadonlyNonEmptyArray.
ReadonlyNonEmptyArray 分割成长度为 n 的片段。如果 n 没有平分 ReadonlyNonEmptyArray 的长度,那么最后一段会更短。

Signature 签名

export declare const chunksOf: (
  n: number
) => <A>(as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<ReadonlyNonEmptyArray<A>>

Added in v2.10.0 v2.10.0 中添加

concat   连接

Signature 签名

export declare function concat<A>(
  second: ReadonlyNonEmptyArray<A>
): (first: ReadonlyArray<A>) => ReadonlyNonEmptyArray<A>
export declare function concat<A>(
  second: ReadonlyArray<A>
): (first: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>
export declare function concat<A>(first: ReadonlyArray<A>, second: ReadonlyNonEmptyArray<A>): ReadonlyNonEmptyArray<A>
export declare function concat<A>(first: ReadonlyNonEmptyArray<A>, second: ReadonlyArray<A>): ReadonlyNonEmptyArray<A>

Added in v2.5.0 v2.5.0中添加

concatAll   全部连接

Signature 签名

export declare const concatAll: <A>(S: Se.Semigroup<A>) => (as: ReadonlyNonEmptyArray<A>) => A

Added in v2.10.0 v2.10.0 中添加

concatW   连接W

Signature 签名

export declare function concatW<B>(
  second: ReadonlyNonEmptyArray<B>
): <A>(first: ReadonlyArray<A>) => ReadonlyNonEmptyArray<A | B>
export declare function concatW<B>(
  second: ReadonlyArray<B>
): <A>(first: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A | B>

Added in v2.11.0 v2.11.0 中添加

duplicate   复制

Signature 签名

export declare const duplicate: <A>(ma: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<ReadonlyNonEmptyArray<A>>

Added in v2.5.0 v2.5.0中添加

extend   延长

Signature 签名

export declare const extend: <A, B>(
  f: (as: ReadonlyNonEmptyArray<A>) => B
) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<B>

Added in v2.5.0 v2.5.0中添加

getUnionSemigroup   获取UnionSemigroup

Signature 签名

export declare const getUnionSemigroup: <A>(E: Eq<A>) => Se.Semigroup<ReadonlyNonEmptyArray<A>>

Added in v2.11.0 v2.11.0 中添加

group   团体

Group equal, consecutive elements of a ReadonlyArray into ReadonlyNonEmptyArrays.
ReadonlyArray 中相等的连续元素分组到 ReadonlyNonEmptyArray 中。

Signature 签名

export declare function group<B>(E: Eq<B>): {
  <A extends B>(as: ReadonlyNonEmptyArray<A>): ReadonlyNonEmptyArray<ReadonlyNonEmptyArray<A>>
  <A extends B>(as: ReadonlyArray<A>): ReadonlyArray<ReadonlyNonEmptyArray<A>>
}

Example 例子

import { group } from 'fp-ts/ReadonlyNonEmptyArray'
import * as N from 'fp-ts/number'

assert.deepStrictEqual(group(N.Eq)([1, 2, 1, 1]), [[1], [2], [1, 1]])

Added in v2.5.0 v2.5.0中添加

groupBy   通过...分组

Splits an array into sub-non-empty-arrays stored in an object, based on the result of calling a string-returning function on each element, and grouping the results according to values returned
根据对每个元素调用 string 返回函数的结果,将数组拆分为存储在对象中的子非空数组,并根据返回的值对结果进行分组

Signature 签名

export declare const groupBy: <A>(
  f: (a: A) => string
) => (as: readonly A[]) => Readonly<Record<string, ReadonlyNonEmptyArray<A>>>

Example 例子

import { groupBy } from 'fp-ts/ReadonlyNonEmptyArray'

assert.deepStrictEqual(groupBy((s: string) => String(s.length))(['a', 'b', 'ab']), {
  '1': ['a', 'b'],
  '2': ['ab'],
})

Added in v2.5.0 v2.5.0中添加

Signature 签名

export declare const head: <A>(as: ReadonlyNonEmptyArray<A>) => A

Added in v2.5.0 v2.5.0中添加

init   在里面

Get all but the last element of a non empty array, creating a new array.
获取非空数组中除最后一个元素之外的所有元素,创建一个新数组。

Signature 签名

export declare const init: <A>(as: ReadonlyNonEmptyArray<A>) => readonly A[]

Example 例子

import { init } from 'fp-ts/ReadonlyNonEmptyArray'

assert.deepStrictEqual(init([1, 2, 3]), [1, 2])
assert.deepStrictEqual(init([1]), [])

Added in v2.5.0 v2.5.0中添加

intercalate  

Places an element in between members of a ReadonlyNonEmptyArray, then folds the results using the provided Semigroup.
将一个元素放置在 ReadonlyNonEmptyArray 的成员之间,然后使用提供的 Semigroup 折叠结果。

Signature 签名

export declare const intercalate: <A>(S: Se.Semigroup<A>) => (middle: A) => (as: ReadonlyNonEmptyArray<A>) => A

Example 例子

import * as S from 'fp-ts/string'
import { intercalate } from 'fp-ts/ReadonlyNonEmptyArray'

assert.deepStrictEqual(intercalate(S.Semigroup)('-')(['a', 'b', 'c']), 'a-b-c')

Added in v2.12.0 v2.12.0 中添加

intersperse   散布

Places an element in between members of a ReadonlyNonEmptyArray.
将元素放置在 ReadonlyNonEmptyArray 的成员之间。

Signature 签名

export declare const intersperse: <A>(middle: A) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>

Example 例子

import { intersperse } from 'fp-ts/ReadonlyNonEmptyArray'

assert.deepStrictEqual(intersperse(9)([1, 2, 3, 4]), [1, 9, 2, 9, 3, 9, 4])

Added in v2.9.0 v2.9.0中添加

last   最后的

Signature 签名

export declare const last: <A>(as: ReadonlyNonEmptyArray<A>) => A

Added in v2.5.0 v2.5.0中添加

max   最大限度

Signature 签名

export declare const max: <A>(O: Ord<A>) => (as: ReadonlyNonEmptyArray<A>) => A

Added in v2.5.0 v2.5.0中添加

min   分钟

Signature 签名

export declare const min: <A>(O: Ord<A>) => (as: ReadonlyNonEmptyArray<A>) => A

Added in v2.5.0 v2.5.0中添加

modifyAt   修改处

Signature 签名

export declare const modifyAt: <A>(
  i: number,
  f: (a: A) => A
) => (as: ReadonlyNonEmptyArray<A>) => Option<ReadonlyNonEmptyArray<A>>

Added in v2.5.0 v2.5.0中添加

modifyHead   修改头

Apply a function to the head, creating a new ReadonlyNonEmptyArray.
将函数应用于头部,创建一个新的 ReadonlyNonEmptyArray

Signature 签名

export declare const modifyHead: <A>(f: Endomorphism<A>) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>

Added in v2.11.0 v2.11.0 中添加

modifyLast   修改最后一个

Apply a function to the last element, creating a new ReadonlyNonEmptyArray.
将函数应用于最后一个元素,创建一个新的 ReadonlyNonEmptyArray

Signature 签名

export declare const modifyLast: <A>(f: Endomorphism<A>) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>

Added in v2.11.0 v2.11.0 中添加

prependAll   前置所有

Prepend an element to every member of a ReadonlyNonEmptyArray.
ReadonlyNonEmptyArray 的每个成员前面添加一个元素。

Signature 签名

export declare const prependAll: <A>(middle: A) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>

Example 例子

import { prependAll } from 'fp-ts/ReadonlyNonEmptyArray'

assert.deepStrictEqual(prependAll(9)([1, 2, 3, 4]), [9, 1, 9, 2, 9, 3, 9, 4])

Added in v2.10.0 v2.10.0 中添加

reverse   撤销

Signature 签名

export declare const reverse: <A>(as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>

Added in v2.5.0 v2.5.0中添加

rotate   旋转

Rotate a ReadonlyNonEmptyArray by n steps.
ReadonlyNonEmptyArray 旋转 n 步。

Signature 签名

export declare const rotate: (n: number) => <A>(as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>

Example 例子

import { rotate } from 'fp-ts/ReadonlyNonEmptyArray'

assert.deepStrictEqual(rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])
assert.deepStrictEqual(rotate(-2)([1, 2, 3, 4, 5]), [3, 4, 5, 1, 2])

Added in v2.11.0 v2.11.0 中添加

sort   种类

Signature 签名

export declare const sort: <B>(O: Ord<B>) => <A extends B>(as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>

Added in v2.5.0 v2.5.0中添加

sortBy   排序方式

Sort the elements of a ReadonlyNonEmptyArray in increasing order, where elements are compared using first ords[0], then ords[1], etc…
按升序对 ReadonlyNonEmptyArray 的元素进行排序,其中首先使用 ords[0] 比较元素,然后使用 ords[1] 等进行比较...

Signature 签名

export declare const sortBy: <B>(
  ords: readonly Ord<B>[]
) => <A extends B>(as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>

Example 例子

import * as RNEA from 'fp-ts/ReadonlyNonEmptyArray'
import { contramap } from 'fp-ts/Ord'
import * as S from 'fp-ts/string'
import * as N from 'fp-ts/number'
import { pipe } from 'fp-ts/function'

interface Person {
  name: string
  age: number
}

const byName = pipe(
  S.Ord,
  contramap((p: Person) => p.name)
)

const byAge = pipe(
  N.Ord,
  contramap((p: Person) => p.age)
)

const sortByNameByAge = RNEA.sortBy([byName, byAge])

const persons: RNEA.ReadonlyNonEmptyArray<Person> = [
  { name: 'a', age: 1 },
  { name: 'b', age: 3 },
  { name: 'c', age: 2 },
  { name: 'b', age: 2 },
]

assert.deepStrictEqual(sortByNameByAge(persons), [
  { name: 'a', age: 1 },
  { name: 'b', age: 2 },
  { name: 'b', age: 3 },
  { name: 'c', age: 2 },
])

Added in v2.11.0 v2.11.0 中添加

splitAt   分割点

Splits a ReadonlyNonEmptyArray into two pieces, the first piece has max n elements.
ReadonlyNonEmptyArray 分成两部分,第一部分最多包含 n 元素。

Signature 签名

export declare const splitAt: (
  n: number
) => <A>(as: ReadonlyNonEmptyArray<A>) => readonly [ReadonlyNonEmptyArray<A>, readonly A[]]

Added in v2.10.0 v2.10.0 中添加

tail   尾巴

Signature 签名

export declare const tail: <A>(as: ReadonlyNonEmptyArray<A>) => readonly A[]

Added in v2.5.0 v2.5.0中添加

unappend   取消附加

Return the tuple of the init and the last.
返回 initlast 的元组。

Signature 签名

export declare const unappend: <A>(as: ReadonlyNonEmptyArray<A>) => readonly [readonly A[], A]

Example 例子

import { unappend } from 'fp-ts/ReadonlyNonEmptyArray'

assert.deepStrictEqual(unappend([1, 2, 3, 4]), [[1, 2, 3], 4])

Added in v2.9.0 v2.9.0中添加

union   联盟

Signature 签名

export declare const union: <A>(
  E: Eq<A>
) => (second: ReadonlyNonEmptyArray<A>) => (first: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>

Added in v2.11.0 v2.11.0 中添加

uniq   独特的

Remove duplicates from a ReadonlyNonEmptyArray, keeping the first occurrence of an element.
ReadonlyNonEmptyArray 中删除重复项,保留元素的第一次出现。

Signature 签名

export declare const uniq: <A>(E: Eq<A>) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>

Example 例子

import { uniq } from 'fp-ts/ReadonlyNonEmptyArray'
import * as N from 'fp-ts/number'

assert.deepStrictEqual(uniq(N.Eq)([1, 2, 1]), [1, 2])

Added in v2.11.0 v2.11.0 中添加

unprepend   取消前置

Return the tuple of the head and the tail.
返回 headtail 的元组。

Signature 签名

export declare const unprepend: <A>(as: ReadonlyNonEmptyArray<A>) => readonly [A, readonly A[]]

Example 例子

import { unprepend } from 'fp-ts/ReadonlyNonEmptyArray'

assert.deepStrictEqual(unprepend([1, 2, 3, 4]), [1, [2, 3, 4]])

Added in v2.9.0 v2.9.0中添加

unzip   解压

Signature 签名

export declare const unzip: <A, B>(
  abs: ReadonlyNonEmptyArray<readonly [A, B]>
) => readonly [ReadonlyNonEmptyArray<A>, ReadonlyNonEmptyArray<B>]

Added in v2.5.1 v2.5.1 中添加

updateAt   更新时间

Signature 签名

export declare const updateAt: <A>(
  i: number,
  a: A
) => (as: ReadonlyNonEmptyArray<A>) => Option<ReadonlyNonEmptyArray<A>>

Added in v2.5.0 v2.5.0中添加

updateHead   更新头

Change the head, creating a new ReadonlyNonEmptyArray.
更改头部,创建一个新的 ReadonlyNonEmptyArray

Signature 签名

export declare const updateHead: <A>(a: A) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>

Added in v2.11.0 v2.11.0 中添加

updateLast   更新最后

Change the last element, creating a new ReadonlyNonEmptyArray.
更改最后一个元素,创建一个新的 ReadonlyNonEmptyArray

Signature 签名

export declare const updateLast: <A>(a: A) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>

Added in v2.11.0 v2.11.0 中添加

zip   压缩

Signature 签名

export declare function zip<B>(
  bs: ReadonlyNonEmptyArray<B>
): <A>(as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<readonly [A, B]>
export declare function zip<A, B>(
  as: ReadonlyNonEmptyArray<A>,
  bs: ReadonlyNonEmptyArray<B>
): ReadonlyNonEmptyArray<readonly [A, B]>

Added in v2.5.1 v2.5.1 中添加

zipWith   zipWith

Signature 签名

export declare const zipWith: <A, B, C>(
  as: ReadonlyNonEmptyArray<A>,
  bs: ReadonlyNonEmptyArray<B>,
  f: (a: A, b: B) => C
) => ReadonlyNonEmptyArray<C>

Added in v2.5.1 v2.5.1 中添加

zone of death
死亡地带

cons 缺点

Use prepend instead. 请改用 prepend

Signature 签名

export declare function cons<A>(head: A): (tail: ReadonlyArray<A>) => ReadonlyNonEmptyArray<A>
export declare function cons<A>(head: A, tail: ReadonlyArray<A>): ReadonlyNonEmptyArray<A>

Added in v2.5.0 v2.5.0中添加

filterWithIndex 带索引的过滤器

Use filterWithIndex instead. 请改用 filterWithIndex

Signature 签名

export declare const filterWithIndex: <A>(
  predicate: (i: number, a: A) => boolean
) => (as: ReadonlyNonEmptyArray<A>) => Option<ReadonlyNonEmptyArray<A>>

Added in v2.5.0 v2.5.0中添加

filter 筛选

Use filter instead. 请改用 filter

Signature 签名

export declare function filter<A, B extends A>(
  refinement: Refinement<A, B>
): (as: ReadonlyNonEmptyArray<A>) => Option<ReadonlyNonEmptyArray<B>>
export declare function filter<A>(
  predicate: Predicate<A>
): <B extends A>(bs: ReadonlyNonEmptyArray<B>) => Option<ReadonlyNonEmptyArray<B>>
export declare function filter<A>(
  predicate: Predicate<A>
): (as: ReadonlyNonEmptyArray<A>) => Option<ReadonlyNonEmptyArray<A>>

Added in v2.5.0 v2.5.0中添加

fold 折叠

Use concatAll instead. 请改用 concatAll

Signature 签名

export declare const fold: <A>(S: Se.Semigroup<A>) => (as: ReadonlyNonEmptyArray<A>) => A

Added in v2.5.0 v2.5.0中添加

groupSort 分组排序

This is just sort followed by group.
这只是 sort 后面跟着 group

Signature 签名

export declare function groupSort<B>(O: Ord<B>): {
  <A extends B>(as: ReadonlyNonEmptyArray<A>): ReadonlyNonEmptyArray<ReadonlyNonEmptyArray<A>>
  <A extends B>(as: ReadonlyArray<A>): ReadonlyArray<ReadonlyNonEmptyArray<A>>
}

Added in v2.5.0 v2.5.0中添加

insertAt 插入位置

Use insertAt instead. 请改用 insertAt

Signature 签名

export declare const insertAt: <A>(i: number, a: A) => (as: readonly A[]) => Option<ReadonlyNonEmptyArray<A>>

Added in v2.5.0 v2.5.0中添加

prependToAll 前置到全部

Use prependAll instead. 请改用 prependAll

Signature 签名

export declare const prependToAll: <A>(middle: A) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>

Added in v2.9.0 v2.9.0中添加

readonlyNonEmptyArray 只读非空数组

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass RNEA.Functor instead of RNEA.readonlyNonEmptyArray (where RNEA is from import RNEA from 'fp-ts/ReadonlyNonEmptyArray')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 RNEA.Functor 而不是 RNEA.readonlyNonEmptyArray (其中 RNEA 来自 import RNEA from 'fp-ts/ReadonlyNonEmptyArray'

Signature 签名

export declare const readonlyNonEmptyArray: Monad1<'ReadonlyNonEmptyArray'> &
  Comonad1<'ReadonlyNonEmptyArray'> &
  TraversableWithIndex1<'ReadonlyNonEmptyArray', number> &
  FunctorWithIndex1<'ReadonlyNonEmptyArray', number> &
  FoldableWithIndex1<'ReadonlyNonEmptyArray', number> &
  Alt1<'ReadonlyNonEmptyArray'>

Added in v2.5.0 v2.5.0中添加

snoc 斯诺克

Use append instead. 请改用 append

Signature 签名

export declare const snoc: <A>(init: readonly A[], end: A) => ReadonlyNonEmptyArray<A>

Added in v2.5.0 v2.5.0中添加

uncons 不合理

Use unprepend instead. 请改用 unprepend

Signature 签名

export declare const uncons: <A>(as: ReadonlyNonEmptyArray<A>) => readonly [A, readonly A[]]

Added in v2.10.0 v2.10.0 中添加

unsnoc 联合国国家奥委会

Use unappend instead. 请改用 unappend

Signature 签名

export declare const unsnoc: <A>(as: ReadonlyNonEmptyArray<A>) => readonly [readonly A[], A]

Added in v2.10.0 v2.10.0 中添加

ReadonlyRecord overview
只读记录概述

The ReadonlyRecord.ts module enables dealing in a functional way with Typescript’s Readonly<Record<K, T>> type. That is similar to the Record.ts module, but for a record with all properties declared as readonly.
ReadonlyRecord.ts 模块能够以函数式方式处理 Typescript 的 Readonly<Record<K, T>> 类型。这与 Record.ts 模块类似,但用于所有属性声明为 readonly 的记录。

Added in v2.5.0 v2.5.0中添加


Table of contents
目录


constructors  构造函数

singleton   单例

Create a ReadonlyRecord with one key/value pair.
使用一个键/值对创建一个 ReadonlyRecord

Signature 签名

export declare const singleton: <A>(k: string, a: A) => Readonly<Record<string, A>>

Example 例子

import { singleton } from 'fp-ts/ReadonlyRecord'

assert.deepStrictEqual(singleton('a', 1), { a: 1 })

Added in v2.5.0 v2.5.0中添加

conversions   转换

fromEntries   来自条目

Converts a ReadonlyArray of [key, value] tuples into a ReadonlyRecord.
[key, value] 元组的 ReadonlyArray 转换为 ReadonlyRecord

Signature 签名

export declare const fromEntries: <A>(fa: readonly (readonly [string, A])[]) => Readonly<Record<string, A>>

Example 例子

import { fromEntries } from 'fp-ts/ReadonlyRecord'

assert.deepStrictEqual(
  fromEntries([
    ['a', 1],
    ['b', 2],
    ['a', 3],
  ]),
  { b: 2, a: 3 }
)

Added in v2.12.0 v2.12.0 中添加

fromRecord   来自记录

Builds a ReadonlyRecord by copying a Record.
通过复制 Record 构建 ReadonlyRecord

Signature 签名

export declare const fromRecord: <K extends string, A>(r: Record<K, A>) => Readonly<Record<K, A>>

Example 例子

import { ReadonlyRecord, fromRecord } from 'fp-ts/ReadonlyRecord'

const x: Record<string, number> = { a: 1, b: 2 }
const y: ReadonlyRecord<string, number> = fromRecord(x)
assert.deepStrictEqual(x, y)
// `y.a = 5` gives compiler error

Added in v2.5.0 v2.5.0中添加

toEntries   至条目

Alias of toReadonlyArray.  toReadonlyArray 的别名。

Signature 签名

export declare const toEntries: <K extends string, A>(r: Readonly<Record<K, A>>) => readonly (readonly [K, A])[]

Example 例子

import { toEntries } from 'fp-ts/ReadonlyRecord'

assert.deepStrictEqual(toEntries({ b: 2, a: 1 }), [
  ['a', 1],
  ['b', 2],
])

Added in v2.12.0 v2.12.0 中添加

toReadonlyArray   到只读数组

Get a sorted ReadonlyArray of the key/value pairs contained in a ReadonlyRecord.
获取 ReadonlyRecord 中包含的键/值对的排序 ReadonlyArray

Signature 签名

export declare const toReadonlyArray: <K extends string, A>(r: Readonly<Record<K, A>>) => readonly (readonly [K, A])[]

Example 例子

import { toReadonlyArray } from 'fp-ts/ReadonlyRecord'

const x = { c: 3, a: 'foo', b: false }
assert.deepStrictEqual(toReadonlyArray(x), [
  ['a', 'foo'],
  ['b', false],
  ['c', 3],
])

Added in v2.5.0 v2.5.0中添加

toRecord   记录

Builds a mutable Record from a ReadonlyRecord.
ReadonlyRecord 构建可变的 Record

Signature 签名

export declare const toRecord: <K extends string, A>(r: Readonly<Record<K, A>>) => Record<K, A>

Example 例子

import { ReadonlyRecord, toRecord } from 'fp-ts/ReadonlyRecord'

const x: ReadonlyRecord<string, number> = { a: 1, b: 2 }
const y: Record<string, number> = toRecord(x)
assert.deepStrictEqual(x, y)
y.a = 5 // it's ok, y is mutable

Added in v2.5.0 v2.5.0中添加

toUnfoldable   至可展开

Unfolds a ReadonlyRecord into a list of key/value pairs.
ReadonlyRecord 展开为键/值对列表。

Given an Unfoldable class type U such as array or readonlyArray, it uses the unfold function to create an instance of U, providing an iterating function that iterates over each key/value pair in the record sorted alphabetically by key.
给定一个 Unfoldable 类类型 U ,例如 arrayreadonlyArray ,它使用 unfold 函数创建 U 的实例,提供迭代函数来迭代记录按字母顺序按键排序。

Signature 签名

export declare function toUnfoldable<F extends URIS>(
  U: Unfoldable1<F>
): <K extends string, A>(r: ReadonlyRecord<K, A>) => Kind<F, readonly [K, A]>
export declare function toUnfoldable<F>(
  U: Unfoldable<F>
): <K extends string, A>(r: ReadonlyRecord<K, A>) => HKT<F, readonly [K, A]>

Example 例子

import { array, readonlyArray } from 'fp-ts'
import { toUnfoldable } from 'fp-ts/ReadonlyRecord'

assert.deepStrictEqual(toUnfoldable(array)({ b: 2, a: 1 }), [
  ['a', 1],
  ['b', 2],
])
assert.deepStrictEqual(toUnfoldable(readonlyArray)({ b: 2, a: 1 }), [
  ['a', 1],
  ['b', 2],
])

Added in v2.5.0 v2.5.0中添加

filtering   过滤

compact   袖珍的

Compact a ReadonlyRecord of Options discarding the None values and keeping the Some values.
压缩 OptionReadonlyRecord ,丢弃 None 值并保留 Some 值。

Signature 签名

export declare const compact: <A>(r: Readonly<Record<string, Option<A>>>) => Readonly<Record<string, A>>

Example 例子

import { compact } from 'fp-ts/ReadonlyRecord'
import { option } from 'fp-ts'

assert.deepStrictEqual(compact({ a: option.some('foo'), b: option.none, c: option.some('bar') }), {
  a: 'foo',
  c: 'bar',
})

Added in v2.5.0 v2.5.0中添加

filter   筛选

Given a Predicate, it produces a new ReadonlyRecord keeping only the entries with a value that satisfies the provided predicate.
给定一个 Predicate ,它会生成一个新的 ReadonlyRecord ,仅保留具有满足所提供谓词的值的条目。

Signature 签名

export declare const filter: {
  <A, B extends A>(refinement: Refinement<A, B>): (fa: Readonly<Record<string, A>>) => Readonly<Record<string, B>>
  <A>(predicate: Predicate<A>): <B extends A>(fb: Readonly<Record<string, B>>) => Readonly<Record<string, B>>
  <A>(predicate: Predicate<A>): (fa: Readonly<Record<string, A>>) => Readonly<Record<string, A>>
}

Example 例子

import { filter } from 'fp-ts/ReadonlyRecord'

assert.deepStrictEqual(filter((s: string) => s.length < 4)({ a: 'foo', b: 'bar', c: 'verylong' }), {
  a: 'foo',
  b: 'bar',
})

Added in v2.5.0 v2.5.0中添加

filterMap   过滤映射

Maps a ReadonlyRecord with an iterating function that returns an Option and it keeps only the Some values discarding the Nones.
使用返回 Option 的迭代函数映射 ReadonlyRecord ,并且仅保留 Some 值并丢弃 None

Signature 签名

export declare const filterMap: <A, B>(
  f: (a: A) => Option<B>
) => (fa: Readonly<Record<string, A>>) => Readonly<Record<string, B>>

Example 例子

import { filterMap } from 'fp-ts/ReadonlyRecord'
import { option } from 'fp-ts'

const f = (s: string) => (s.length < 4 ? option.some(`${s} is short`) : option.none)
assert.deepStrictEqual(filterMap(f)({ a: 'foo', b: 'bar', c: 'verylong' }), {
  a: 'foo is short',
  b: 'bar is short',
})

Added in v2.5.0 v2.5.0中添加

getWitherable   变得枯萎

Signature 签名

export declare const getWitherable: (O: Ord<string>) => Witherable1<URI>

Added in v2.11.0 v2.11.0 中添加

partition   分割

Partition a ReadonlyRecord into two parts according to a Predicate.
根据 PredicateReadonlyRecord 分成两部分。

Signature 签名

export declare const partition: {
  <A, B extends A>(refinement: Refinement<A, B>): (
    fa: Readonly<Record<string, A>>
  ) => Separated<Readonly<Record<string, A>>, Readonly<Record<string, B>>>
  <A>(predicate: Predicate<A>): <B extends A>(
    fb: Readonly<Record<string, B>>
  ) => Separated<Readonly<Record<string, B>>, Readonly<Record<string, B>>>
  <A>(predicate: Predicate<A>): (
    fa: Readonly<Record<string, A>>
  ) => Separated<Readonly<Record<string, A>>, Readonly<Record<string, A>>>
}

Example 例子

import { partition } from 'fp-ts/ReadonlyRecord'

assert.deepStrictEqual(partition((s: string) => s.length < 4)({ a: 'foo', b: 'bar', c: 'verylong' }), {
  left: {
    c: 'verylong',
  },
  right: {
    a: 'foo',
    b: 'bar',
  },
})

Added in v2.5.0 v2.5.0中添加

partitionMap   分区图

Maps a ReadonlyRecord with a function returning an Either and partitions the resulting ReadonlyRecord into Lefts and Rights.
ReadonlyRecord 映射到返回 Either 的函数,并将生成的 ReadonlyRecord 划分为 LeftRight

Signature 签名

export declare const partitionMap: <A, B, C>(
  f: (a: A) => Either<B, C>
) => (fa: Readonly<Record<string, A>>) => Separated<Readonly<Record<string, B>>, Readonly<Record<string, C>>>

Example 例子

import { partitionMap } from 'fp-ts/ReadonlyRecord'
import { either } from 'fp-ts'

const f = (s: string) => (s.length < 4 ? either.right(`${s} is short`) : either.left(`${s} is not short`))
assert.deepStrictEqual(partitionMap(f)({ a: 'foo', b: 'bar', c: 'verylong' }), {
  left: {
    c: 'verylong is not short',
  },
  right: {
    a: 'foo is short',
    b: 'bar is short',
  },
})

Added in v2.5.0 v2.5.0中添加

separate   分离

Separate a ReadonlyRecord of Eithers into Lefts and Rights.
Either 中的 ReadonlyRecord 分成 LeftRight

Signature 签名

export declare const separate: <A, B>(
  r: Readonly<Record<string, Either<A, B>>>
) => Separated<Readonly<Record<string, A>>, Readonly<Record<string, B>>>

Example 例子

import { separate } from 'fp-ts/ReadonlyRecord'
import { either } from 'fp-ts'

assert.deepStrictEqual(separate({ a: either.right('foo'), b: either.left('bar'), c: either.right('baz') }), {
  right: {
    a: 'foo',
    c: 'baz',
  },
  left: {
    b: 'bar',
  },
})

Added in v2.5.0 v2.5.0中添加

wilt   枯萎

Signature 签名

export declare const wilt: PipeableWilt1<'ReadonlyRecord'>

Added in v2.6.5 v2.6.5 中添加

wither   枯萎

Signature 签名

export declare const wither: PipeableWither1<'ReadonlyRecord'>

Added in v2.6.5 v2.6.5 中添加

folding   折叠式的

foldMap   折叠图

Map and fold a ReadonlyRecord. Map the ReadonlyRecord passing each value to the iterating function. Then fold the results using the provided Monoid.
映射并折叠 ReadonlyRecord 。映射 ReadonlyRecord 将每个值传递给迭代函数。然后使用提供的 Monoid 折叠结果。

Signature 签名

export declare function foldMap(
  O: Ord<string>
): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: ReadonlyRecord<string, A>) => M
export declare function foldMap<M>(M: Monoid<M>): <A>(f: (a: A) => M) => (fa: ReadonlyRecord<string, A>) => M

Example 例子

import { foldMap } from 'fp-ts/ReadonlyRecord'
import { Ord } from 'fp-ts/string'
import { Monoid } from 'fp-ts/Monoid'

const m: Monoid<string> = { empty: '', concat: (x: string, y: string) => (x ? `${x} -> ${y}` : `${y}`) }
const f = (a: number) => `-${a}-`
const x = { c: 3, a: 1, b: 2 }
assert.deepStrictEqual(foldMap(Ord)(m)(f)(x), '-1- -> -2- -> -3-')

Added in v2.5.0 v2.5.0中添加

getFoldable   获取可折叠的

Produces a Foldable instance for a ReadonlyRecord, using the provided Ord to sort the ReadonlyRecord’s entries by key.
ReadonlyRecord 生成一个 Foldable 实例,使用提供的 Ord 按键对 ReadonlyRecord 的条目进行排序。

Signature 签名

export declare const getFoldable: (O: Ord<string>) => Foldable1<URI>

Added in v2.11.0 v2.11.0 中添加

getFoldableWithIndex   获取FoldableWithIndex

Produces a FoldableWithIndex1 instance for a ReadonlyRecord, using the provided Ord to sort the ReadonlyRecord’s entries by key.
ReadonlyRecord 生成一个 FoldableWithIndex1 实例,使用提供的 Ord 按键对 ReadonlyRecord 的条目进行排序。

Signature 签名

export declare const getFoldableWithIndex: (O: Ord<string>) => FoldableWithIndex1<URI, string>

Added in v2.11.0 v2.11.0 中添加

reduce   减少

Reduces a ReadonlyRecord passing each value to the iterating function. Entries are processed in order, sorted by key according to the given Ord.
减少将每个值传递给迭代函数的 ReadonlyRecord 。条目按顺序处理,根据给定的 Ord 按键排序。

Signature 签名

export declare function reduce(
  O: Ord<string>
): <A, B>(b: B, f: (b: B, a: A) => B) => (fa: ReadonlyRecord<string, A>) => B
export declare function reduce<A, B>(b: B, f: (b: B, a: A) => B): (fa: ReadonlyRecord<string, A>) => B

Example 例子

import { reduce } from 'fp-ts/ReadonlyRecord'
import { Ord } from 'fp-ts/string'

const x = { c: 3, a: 'foo', b: false }
assert.deepStrictEqual(reduce(Ord)([] as string[], (b, a) => [...b, `-${a}-`])(x), ['-foo-', '-false-', '-3-'])

Added in v2.5.0 v2.5.0中添加

reduceRight   减少右

Same as reduce but entries are processed from the right, i.e. in reverse order, from the last to the first entry, according to the given Ord.
reduce 相同,但根据给定的 Ord ,从右侧开始处理条目,即以相反的顺序,从最后一个条目到第一个条目。

Signature 签名

export declare function reduceRight(
  O: Ord<string>
): <A, B>(b: B, f: (a: A, b: B) => B) => (fa: ReadonlyRecord<string, A>) => B
export declare function reduceRight<A, B>(b: B, f: (a: A, b: B) => B): (fa: ReadonlyRecord<string, A>) => B

Example 例子

import { reduceRight } from 'fp-ts/ReadonlyRecord'
import { Ord } from 'fp-ts/string'

const x = { c: 3, a: 'foo', b: false }
assert.deepStrictEqual(reduceRight(Ord)([] as string[], (a, b) => [...b, `-${a}-`])(x), ['-3-', '-false-', '-foo-'])

Added in v2.5.0 v2.5.0中添加

instances   实例

Compactable   紧凑型

Signature 签名

export declare const Compactable: Compactable1<'ReadonlyRecord'>

Added in v2.7.0 v2.7.0 中添加

Filterable   可过滤

Signature 签名

export declare const Filterable: Filterable1<'ReadonlyRecord'>

Added in v2.7.0 v2.7.0 中添加

FilterableWithIndex   可通过索引过滤

Signature 签名

export declare const FilterableWithIndex: FilterableWithIndex1<'ReadonlyRecord', string>

Added in v2.7.0 v2.7.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor1<'ReadonlyRecord'>

Added in v2.7.0 v2.7.0 中添加

FunctorWithIndex   带索引的函子

Signature 签名

export declare const FunctorWithIndex: FunctorWithIndex1<'ReadonlyRecord', string>

Added in v2.7.0 v2.7.0 中添加

getDifferenceMagma   获取差异岩浆

Produces a Magma with a concat function that combines two ReadonlyRecords by making the difference.
使用 concat 函数生成 Magma ,该函数通过创建 difference 来组合两个 ReadonlyRecord

Signature 签名

export declare const getDifferenceMagma: <A>() => Magma<Readonly<Record<string, A>>>

Example 例子

import { getDifferenceMagma, difference, ReadonlyRecord } from 'fp-ts/ReadonlyRecord'
import { Magma } from 'fp-ts/Magma'

const r1 = { a: 3, c: 3 }
const r2 = { a: 1, b: 2 }
const m: Magma<ReadonlyRecord<string, number>> = getDifferenceMagma<number>()
assert.deepStrictEqual(m.concat(r1, r2), difference(r2)(r1))
assert.deepStrictEqual(m.concat(r1, r2), { c: 3, b: 2 })

Added in v2.11.0 v2.11.0 中添加

getEq   得到方程

Given an Eq for the base type, it produces an Eq for a ReadonlyRecord of that base type.
给定基本类型的 Eq ,它会为该基本类型的 ReadonlyRecord 生成 Eq

Signature 签名

export declare function getEq<K extends string, A>(E: Eq<A>): Eq<ReadonlyRecord<K, A>>

Example 例子

import { getEq, ReadonlyRecord } from 'fp-ts/ReadonlyRecord'
import { string } from 'fp-ts'
import { Eq } from 'fp-ts/Eq'

const eq: Eq<ReadonlyRecord<string, string>> = getEq(string.Eq)
assert.deepStrictEqual(eq.equals({ a: 'foo' }, { b: 'bar' }), false)
assert.deepStrictEqual(eq.equals({ a: 'foo' }, { a: 'foo' }), true)

Added in v2.5.0 v2.5.0中添加

getIntersectionSemigroup
获取交集半群

Given a Semigroup in the base type, it produces a Semigroup in the ReadonlyRecord of the base type. The resulting Semigroup concatenates two ReadonlyRecords by intersection.
给定基类型中的 Semigroup ,它会在基类型的 ReadonlyRecord 中生成 Semigroup 。生成的 Semigroup 通过 intersection 连接两个 ReadonlyRecord

Signature 签名

export declare const getIntersectionSemigroup: <A>(S: Se.Semigroup<A>) => Se.Semigroup<Readonly<Record<string, A>>>

Example 例子

import { getIntersectionSemigroup, ReadonlyRecord } from 'fp-ts/ReadonlyRecord'
import { Semigroup } from 'fp-ts/Semigroup'

const sNumber: Semigroup<number> = { concat: (x, y) => x - y }
const sReadonlyRecord: Semigroup<ReadonlyRecord<string, number>> = getIntersectionSemigroup(sNumber)
assert.deepStrictEqual(sReadonlyRecord.concat({ a: 1, b: 2 }, { b: 3, c: 4 }), { b: -1 })

Added in v2.11.0 v2.11.0 中添加

getMonoid   获取Monoid

Returns a Monoid instance for ReadonlyRecords, given a Semigroup instance for the base type. The Monoid makes the union of two ReadonlyRecords comining the overlapping entries with the provided Semigroup.
给定基本类型的 Semigroup 实例,返回 ReadonlyRecord s 的 Monoid 实例。 Monoid 将两个 ReadonlyRecord 进行并集,将重叠条目与提供的 Semigroup 相结合。

Signature 签名

export declare function getMonoid<K extends string, A>(S: Semigroup<A>): Monoid<ReadonlyRecord<K, A>>

Example 例子

import { SemigroupSum } from 'fp-ts/number'
import { getMonoid } from 'fp-ts/ReadonlyRecord'

const M = getMonoid(SemigroupSum)
assert.deepStrictEqual(M.concat({ foo: 123, bar: 234 }, { foo: 456, baz: 567 }), { foo: 579, bar: 234, baz: 567 })

Added in v2.5.0 v2.5.0中添加

getShow   获取显示

Produces a Show for a ReadonlyRecord, given a Show for the base type (a Show produces a human-readable representation of an instance). ReadonlyRecord entries are sorted by key with the provided Ord.
ReadonlyRecord 生成 Show ,给定基本类型 ShowShow 生成实例的人类可读表示)。 ReadonlyRecord 条目使用提供的 Ord 按键排序。

Signature 签名

export declare function getShow(O: Ord<string>): <A>(S: Show<A>) => Show<ReadonlyRecord<string, A>>
export declare function getShow<A>(S: Show<A>): Show<ReadonlyRecord<string, A>>

Example 例子

import { getShow, ReadonlyRecord } from 'fp-ts/ReadonlyRecord'
import { Show } from 'fp-ts/Show'
import { Ord } from 'fp-ts/string'

const sNumber: Show<number> = { show: (n: number) => `${n}` }
const sRecord: Show<ReadonlyRecord<string, number>> = getShow(Ord)(sNumber)
assert.deepStrictEqual(sRecord.show({ b: 2, a: 1 }), '{ "a": 1, "b": 2 }')

Added in v2.5.0 v2.5.0中添加

getUnionMonoid  获取UnionMonoid

Same as getMonoid. Returns a Monoid instance for ReadonlyRecords given a Semigroup instance for the base type. The Monoid makes the union of two ReadonlyRecords combining the entries that have the same key with the provided Semigroup.
getMonoid 相同。给定基本类型的 Semigroup 实例,返回 ReadonlyRecordMonoid 实例。 Monoid 将两个 ReadonlyRecord 进行并集,将具有相同键的条目与提供的 Semigroup 组合起来。

Signature 签名

export declare const getUnionMonoid: <A>(S: Se.Semigroup<A>) => Monoid<Readonly<Record<string, A>>>

Example 例子

import { SemigroupSum } from 'fp-ts/number'
import { getUnionMonoid } from 'fp-ts/ReadonlyRecord'

const M = getUnionMonoid(SemigroupSum)
assert.deepStrictEqual(M.concat({ foo: 123, bar: 234 }, { foo: 456, baz: 567 }), { foo: 579, bar: 234, baz: 567 })

Added in v2.11.0 v2.11.0 中添加

getUnionSemigroup   获取UnionSemigroup

Given a Semigroup in the base type, it produces a Semigroup in the ReadonlyRecord of the base type. The resulting Semigroup concatenates two ReadonlyRecords by union.
给定基类型中的 Semigroup ,它会在基类型的 ReadonlyRecord 中生成 Semigroup 。生成的 Semigroup 通过 union 连接两个 ReadonlyRecord

Signature 签名

export declare const getUnionSemigroup: <A>(S: Se.Semigroup<A>) => Se.Semigroup<Readonly<Record<string, A>>>

Example 例子

import { getUnionSemigroup, ReadonlyRecord } from 'fp-ts/ReadonlyRecord'
import { Semigroup } from 'fp-ts/Semigroup'

const sNumber: Semigroup<number> = { concat: (x, y) => x - y }
const sReadonlyRecord: Semigroup<ReadonlyRecord<string, number>> = getUnionSemigroup(sNumber)
assert.deepStrictEqual(sReadonlyRecord.concat({ a: 1, b: 2 }, { b: 3, c: 4 }), { a: 1, b: -1, c: 4 })

Added in v2.11.0 v2.11.0 中添加

mapping   映射

flap   皮瓣

Takes a value and a ReadonlyRecord of functions and returns a ReadonlyRecord by applying each function to the input value.
获取一个值和一个 ReadonlyRecord 函数,并通过将每个函数应用于输入值来返回一个 ReadonlyRecord

Signature 签名

export declare const flap: <A>(a: A) => <B>(fab: Readonly<Record<string, (a: A) => B>>) => Readonly<Record<string, B>>

Example 例子

import { flap } from 'fp-ts/ReadonlyRecord'

const fab = { x: (n: number) => `${n} times 2`, y: (n: number) => `${n * 2}` }
assert.deepStrictEqual(flap(3)(fab), {
  x: '3 times 2',
  y: '6',
})

Added in v2.10.0 v2.10.0 中添加

model   模型

ReadonlyRecord (type alias)
ReadonlyRecord(类型别名)

Signature 签名

export type ReadonlyRecord<K extends string, T> = Readonly<Record<K, T>>

Added in v2.5.0 v2.5.0中添加

traversing   穿越

getTraversable   获取可遍历的

Produces a Traversable instance for a ReadonlyRecord, using the provided Ord to sort the ReadonlyRecord’s entries by key.
ReadonlyRecord 生成一个 Traversable 实例,使用提供的 Ord 按键对 ReadonlyRecord 的条目进行排序。

Signature 签名

export declare const getTraversable: (O: Ord<string>) => Traversable1<URI>

Added in v2.11.0 v2.11.0 中添加

getTraversableWithIndex
getTraversableWithIndex

Produces a TraversableWithIndex instance for a ReadonlyRecord, using the provided Ord to sort the ReadonlyRecord’s entries by key.
ReadonlyRecord 生成一个 TraversableWithIndex 实例,使用提供的 Ord 按键对 ReadonlyRecord 的条目进行排序。

Signature 签名

export declare const getTraversableWithIndex: (O: Ord<string>) => TraversableWithIndex1<URI, string>

Added in v2.11.0 v2.11.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'ReadonlyRecord'

Added in v2.5.0 v2.5.0中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.5.0 v2.5.0中添加

utils   实用程序

collect   收集

Map a ReadonlyRecord into an ReadonlyArray.
ReadonlyRecord 映射到 ReadonlyArray

Signature 签名

export declare function collect(
  O: Ord<string>
): <K extends string, A, B>(f: (k: K, a: A) => B) => (r: ReadonlyRecord<K, A>) => ReadonlyArray<B>
export declare function collect<K extends string, A, B>(
  f: (k: K, a: A) => B
): (r: ReadonlyRecord<K, A>) => ReadonlyArray<B>

Example 例子

import { collect } from 'fp-ts/ReadonlyRecord'
import { Ord } from 'fp-ts/string'

const f = <A>(k: string, a: A) => `${k.toUpperCase()}-${a}`
const x = { c: 3, a: 'foo', b: false }
assert.deepStrictEqual(collect(Ord)(f)(x), ['A-foo', 'B-false', 'C-3'])

Added in v2.5.0 v2.5.0中添加

deleteAt   删除处

Delete a key and value from a ReadonlyRecord.
ReadonlyRecord 中删除键和值。

Signature 签名

export declare function deleteAt<K extends string>(
  k: K
): <KS extends string, A>(r: ReadonlyRecord<KS, A>) => ReadonlyRecord<string extends K ? string : Exclude<KS, K>, A>

Example 例子

import { deleteAt } from 'fp-ts/ReadonlyRecord'

assert.deepStrictEqual(deleteAt('a')({ a: 1, b: 2 }), { b: 2 })
assert.deepStrictEqual(deleteAt('c')({ a: 1, b: 2 }), { a: 1, b: 2 })

Added in v2.5.0 v2.5.0中添加

difference   不同之处

Difference between two ReadonlyRecords. Takes two ReadonlyRecords and produces a ReadonlyRecord composed by the entries of the two inputs, removing the entries with the same key in both inputs.
两个 ReadonlyRecord 之间的差异。获取两个 ReadonlyRecord 并生成由两个输入的条目组成的 ReadonlyRecord ,删除两个输入中具有相同键的条目。

Signature 签名

export declare const difference: <A>(
  second: Readonly<Record<string, A>>
) => (first: Readonly<Record<string, A>>) => Readonly<Record<string, A>>

Example 例子

import { difference } from 'fp-ts/ReadonlyRecord'

assert.deepStrictEqual(difference({ a: 1 })({ a: 1, b: 2 }), { b: 2 })
assert.deepStrictEqual(difference({ a: 3 })({ a: 1, b: 2 }), { b: 2 })
assert.deepStrictEqual(difference({ a: 3, c: 3 })({ a: 1, b: 2 }), { b: 2, c: 3 })

Added in v2.11.0 v2.11.0 中添加

elem   埃莱姆

Given an Eq checks if a ReadonlyRecord contains an entry with value equal to a provided value.
给定一个 Eq ,检查 ReadonlyRecord 是否包含一个值等于所提供值的条目。

Signature 签名

export declare function elem<A>(E: Eq<A>): {
  (a: A): (fa: ReadonlyRecord<string, A>) => boolean
  (a: A, fa: ReadonlyRecord<string, A>): boolean
}

Example 例子

import { elem } from 'fp-ts/ReadonlyRecord'
import { number } from 'fp-ts'

assert.deepStrictEqual(elem(number.Eq)(123, { foo: 123, bar: 234 }), true)
assert.deepStrictEqual(elem(number.Eq)(-7, { foo: 123, bar: 234 }), false)

Added in v2.5.0 v2.5.0中添加

empty   空的

Signature 签名

export declare const empty: Readonly<Record<string, never>>

Added in v2.5.0 v2.5.0中添加

every   每一个

Test if every value in a ReadonlyRecord satisfies the predicate.
测试 ReadonlyRecord 中的每个值是否满足谓词。

Signature 签名

export declare function every<A, B extends A>(
  refinement: Refinement<A, B>
): Refinement<ReadonlyRecord<string, A>, ReadonlyRecord<string, B>>
export declare function every<A>(predicate: Predicate<A>): Predicate<ReadonlyRecord<string, A>>

Example 例子

import { every } from 'fp-ts/ReadonlyRecord'

assert.deepStrictEqual(every((n: number) => n >= 0)({ a: 1, b: 2 }), true)
assert.deepStrictEqual(every((n: number) => n >= 0)({ a: 1, b: -1 }), false)

Added in v2.5.0 v2.5.0中添加

filterMapWithIndex   带索引的过滤映射

Maps a ReadonlyRecord with an iterating function that takes key and value and returns an Option, keeping only the Some values and discarding Nones.
使用迭代函数映射 ReadonlyRecord ,该迭代函数接受键和值并返回 Option ,仅保留 Some 值并丢弃 None

Signature 签名

export declare function filterMapWithIndex<K extends string, A, B>(
  f: (key: K, a: A) => Option<B>
): (fa: ReadonlyRecord<K, A>) => ReadonlyRecord<string, B>

Example 例子

import { filterMapWithIndex } from 'fp-ts/ReadonlyRecord'
import { option } from 'fp-ts'

const f = (key: string, a: number) => (a >= 0 ? option.some(`${key}${a}`) : option.none)
assert.deepStrictEqual(filterMapWithIndex(f)({ a: -1, b: 2, c: 3 }), {
  b: 'b2',
  c: 'c3',
})

Added in v2.5.0 v2.5.0中添加

filterWithIndex   带索引的过滤器

Produce a new ReadonlyRecord keeping only the entries that satisfy a predicate taking key and value as input.
生成一个新的 ReadonlyRecord ,仅保留满足以键和值作为输入的谓词的条目。

Signature 签名

export declare function filterWithIndex<K extends string, A, B extends A>(
  refinementWithIndex: RefinementWithIndex<K, A, B>
): (fa: ReadonlyRecord<K, A>) => ReadonlyRecord<string, B>
export declare function filterWithIndex<K extends string, A>(
  predicateWithIndex: PredicateWithIndex<K, A>
): <B extends A>(fb: ReadonlyRecord<K, B>) => ReadonlyRecord<string, B>
export declare function filterWithIndex<K extends string, A>(
  predicateWithIndex: PredicateWithIndex<K, A>
): (fa: ReadonlyRecord<K, A>) => ReadonlyRecord<string, A>

Example 例子

import { filterWithIndex } from 'fp-ts/ReadonlyRecord'

assert.deepStrictEqual(filterWithIndex((s: string, v: number) => s.length <= 1 && v > 0)({ a: 1, b: -2, ccc: 3 }), {
  a: 1,
})

Added in v2.5.0 v2.5.0中添加

foldMapWithIndex   带索引的折叠地图

Map and fold a ReadonlyRecord. Map the ReadonlyRecord passing each key/value pair to the iterating function. Then fold the results using the provided Monoid.
映射并折叠 ReadonlyRecord 。映射 ReadonlyRecord ,将每个键/值对传递给迭代函数。然后使用提供的 Monoid 折叠结果。

Signature 签名

export declare function foldMapWithIndex(
  O: Ord<string>
): <M>(M: Monoid<M>) => <K extends string, A>(f: (k: K, a: A) => M) => (fa: ReadonlyRecord<K, A>) => M
export declare function foldMapWithIndex<M>(
  M: Monoid<M>
): <K extends string, A>(f: (k: K, a: A) => M) => (fa: ReadonlyRecord<K, A>) => M

Example 例子

import { foldMapWithIndex } from 'fp-ts/ReadonlyRecord'
import { Ord } from 'fp-ts/string'
import { Monoid } from 'fp-ts/Monoid'

const m: Monoid<string> = { empty: '', concat: (x: string, y: string) => (x ? `${x} -> ${y}` : `${y}`) }
const f = (k: string, a: number) => `${k}-${a}`
const x = { c: 3, a: 1, b: 2 }
assert.deepStrictEqual(foldMapWithIndex(Ord)(m)(f)(x), 'a-1 -> b-2 -> c-3')

Added in v2.5.0 v2.5.0中添加

fromFoldable   来自可折叠

Create a ReadonlyRecord from a foldable collection of key/value pairs, using the specified Magma to combine values for duplicate keys.
从可折叠的键/值对集合创建 ReadonlyRecord ,使用指定的 Magma 来组合重复键的值。

Signature 签名

export declare function fromFoldable<F extends URIS3, A>(
  M: Magma<A>,
  F: Foldable3<F>
): <R, E>(fka: Kind3<F, R, E, readonly [string, A]>) => ReadonlyRecord<string, A>
export declare function fromFoldable<F extends URIS2, A>(
  M: Magma<A>,
  F: Foldable2<F>
): <E>(fka: Kind2<F, E, readonly [string, A]>) => ReadonlyRecord<string, A>
export declare function fromFoldable<F extends URIS, A>(
  M: Magma<A>,
  F: Foldable1<F>
): (fka: Kind<F, readonly [string, A]>) => ReadonlyRecord<string, A>
export declare function fromFoldable<F, A>(
  M: Magma<A>,
  F: FoldableHKT<F>
): (fka: HKT<F, readonly [string, A]>) => ReadonlyRecord<string, A>

Added in v2.5.0 v2.5.0中添加

fromFoldableMap   来自FoldableMap

Create a ReadonlyRecord from a foldable collection using the specified functions to:
使用指定的函数从可折叠集合创建 ReadonlyRecord

  • map to key/value pairs
    映射到键/值对
  • combine values for duplicate keys.
    合并重复键的值。

Signature 签名

export declare function fromFoldableMap<F extends URIS3, B>(
  M: Magma<B>,
  F: Foldable3<F>
): <R, E, A>(fa: Kind3<F, R, E, A>, f: (a: A) => readonly [string, B]) => ReadonlyRecord<string, B>
export declare function fromFoldableMap<F extends URIS2, B>(
  M: Magma<B>,
  F: Foldable2<F>
): <E, A>(fa: Kind2<F, E, A>, f: (a: A) => readonly [string, B]) => ReadonlyRecord<string, B>
export declare function fromFoldableMap<F extends URIS, B>(
  M: Magma<B>,
  F: Foldable1<F>
): <A>(fa: Kind<F, A>, f: (a: A) => readonly [string, B]) => ReadonlyRecord<string, B>
export declare function fromFoldableMap<F, B>(
  M: Magma<B>,
  F: FoldableHKT<F>
): <A>(fa: HKT<F, A>, f: (a: A) => readonly [string, B]) => ReadonlyRecord<string, B>

Example 例子

import { last } from 'fp-ts/Semigroup'
import { Foldable, zip } from 'fp-ts/ReadonlyArray'
import { identity } from 'fp-ts/function'
import { ReadonlyRecord, fromFoldableMap } from 'fp-ts/ReadonlyRecord'

export const zipObject = <K extends string, A>(
  keys: ReadonlyArray<K>,
  values: ReadonlyArray<A>
): ReadonlyRecord<K, A> => fromFoldableMap(last<A>(), Foldable)(zip(keys, values), identity)

assert.deepStrictEqual(zipObject(['a', 'b'], [1, 2, 3]), { a: 1, b: 2 })

interface User {
  readonly id: string
  readonly name: string
}

const users: ReadonlyArray<User> = [
  { id: 'id1', name: 'name1' },
  { id: 'id2', name: 'name2' },
  { id: 'id1', name: 'name3' },
]

assert.deepStrictEqual(
  fromFoldableMap(last<User>(), Foldable)(users, (user) => [user.id, user]),
  {
    id1: { id: 'id1', name: 'name3' },
    id2: { id: 'id2', name: 'name2' },
  }
)

Added in v2.5.0 v2.5.0中添加

has  

Test whether or not a key exists in a ReadonlyRecord.
测试 ReadonlyRecord 中是否存在某个键。

Note. This function is not pipeable because is a Refinement.
笔记。该函数不可通过管道传输,因为它是 Refinement

Signature 签名

export declare const has: <K extends string>(k: string, r: Readonly<Record<K, unknown>>) => k is K

Example 例子

import { has } from 'fp-ts/ReadonlyRecord'

assert.deepStrictEqual(has('a', { a: 1, b: 2 }), true)
assert.deepStrictEqual(has('c', { a: 1, b: 2 }), false)

Added in v2.10.0 v2.10.0 中添加

intersection   路口

Intersection of two ReadonlyRecords. Takes two ReadonlyRecords and produces a ReadonlyRecord combining only the entries of the two inputswith the same key. It uses the concat function of the provided Magma to combine the elements.
两个 ReadonlyRecord 的交集。接受两个 ReadonlyRecord 并生成一个 ReadonlyRecord ,仅组合具有相同键的两个输入的条目。它使用提供的 Magmaconcat 函数来组合元素。

Signature 签名

export declare const intersection: <A>(
  M: Magma<A>
) => (second: Readonly<Record<string, A>>) => (first: Readonly<Record<string, A>>) => Readonly<Record<string, A>>

Example 例子

import { intersection } from 'fp-ts/ReadonlyRecord'
import { Magma } from 'fp-ts/Magma'

const m1: Magma<number> = { concat: (x: number, y: number) => x + y }
assert.deepStrictEqual(intersection(m1)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 4 })
const m2: Magma<number> = { concat: (x: number) => x }
assert.deepStrictEqual(intersection(m2)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 1 })

Added in v2.11.0 v2.11.0 中添加

isEmpty   是空的

Test whether a ReadonlyRecord is empty.
测试 ReadonlyRecord 是否为空。

Signature 签名

export declare const isEmpty: <A>(r: Readonly<Record<string, A>>) => boolean

Example 例子

import { isEmpty } from 'fp-ts/ReadonlyRecord'

assert.deepStrictEqual(isEmpty({}), true)
assert.deepStrictEqual(isEmpty({ a: 3 }), false)

Added in v2.5.0 v2.5.0中添加

isSubrecord   是子记录

Test whether one ReadonlyRecord contains all of the keys and values contained in another ReadonlyRecord.
测试一个 ReadonlyRecord 是否包含另一个 ReadonlyRecord 中包含的所有键和值。

Signature 签名

export declare function isSubrecord<A>(E: Eq<A>): {
  (that: ReadonlyRecord<string, A>): (me: ReadonlyRecord<string, A>) => boolean
  (me: ReadonlyRecord<string, A>, that: ReadonlyRecord<string, A>): boolean
}

Example 例子

import { isSubrecord } from 'fp-ts/ReadonlyRecord'
import { string } from 'fp-ts'

assert.deepStrictEqual(isSubrecord(string.Eq)({ a: 'foo', b: 'bar', c: 'baz' })({ a: 'foo', b: 'bar', c: 'baz' }), true)
assert.deepStrictEqual(isSubrecord(string.Eq)({ a: 'foo', b: 'bar', c: 'baz' })({ a: 'foo', c: 'baz' }), true)
assert.deepStrictEqual(
  isSubrecord(string.Eq)({ a: 'foo', b: 'bar', c: 'baz' })({ a: 'foo', b: 'not-bar', c: 'baz' }),
  false
)
assert.deepStrictEqual(isSubrecord(string.Eq)({ a: 'foo', b: 'bar' })({ a: 'foo', b: 'bar', c: 'baz' }), false)

Added in v2.5.0 v2.5.0中添加

keys  

Signature 签名

export declare const keys: <K extends string>(r: Readonly<Record<K, unknown>>) => readonly K[]

Added in v2.5.0 v2.5.0中添加

lookup   抬头

Lookup the value for a key in a ReadonlyRecord.
ReadonlyRecord 中查找键的值。

Signature 签名

export declare function lookup(k: string): <A>(r: ReadonlyRecord<string, A>) => Option<A>
export declare function lookup<A>(k: string, r: ReadonlyRecord<string, A>): Option<A>

Example 例子

import { lookup } from 'fp-ts/ReadonlyRecord'
import { option } from 'fp-ts'

assert.deepStrictEqual(lookup('b')({ a: 'foo', b: 'bar' }), option.some('bar'))
assert.deepStrictEqual(lookup('c')({ a: 'foo', b: 'bar' }), option.none)

Added in v2.5.0 v2.5.0中添加

map   地图

Map a ReadonlyRecord passing the values to the iterating function.
映射 ReadonlyRecord 将值传递给迭代函数。

Signature 签名

export declare function map<A, B>(f: (a: A) => B): <K extends string>(fa: ReadonlyRecord<K, A>) => ReadonlyRecord<K, B>

Example 例子

import { map } from 'fp-ts/ReadonlyRecord'

const f = (n: number) => `-${n}-`
assert.deepStrictEqual(map(f)({ a: 3, b: 5 }), { a: '-3-', b: '-5-' })

Added in v2.5.0 v2.5.0中添加

mapWithIndex   带索引的映射

Map a ReadonlyRecord passing the keys to the iterating function.
映射 ReadonlyRecord 将键传递给迭代函数。

Signature 签名

export declare function mapWithIndex<K extends string, A, B>(
  f: (k: K, a: A) => B
): (fa: ReadonlyRecord<K, A>) => ReadonlyRecord<K, B>

Example 例子

import { mapWithIndex } from 'fp-ts/ReadonlyRecord'

const f = (k: string, n: number) => `${k.toUpperCase()}-${n}`
assert.deepStrictEqual(mapWithIndex(f)({ a: 3, b: 5 }), { a: 'A-3', b: 'B-5' })

Added in v2.5.0 v2.5.0中添加

modifyAt   修改处

Applies a mapping function to one specific key/value pair in a ReadonlyRecord.
将映射函数应用于 ReadonlyRecord 中的一个特定键/值对。

Signature 签名

export declare const modifyAt: <A>(
  k: string,
  f: (a: A) => A
) => <K extends string>(r: Readonly<Record<K, A>>) => Option<Readonly<Record<K, A>>>

Example 例子

import { modifyAt } from 'fp-ts/ReadonlyRecord'
import { option } from 'fp-ts'

assert.deepStrictEqual(modifyAt('a', (x: number) => x * 3)({ a: 1, b: 2 }), option.some({ a: 3, b: 2 }))
assert.deepStrictEqual(modifyAt('c', (x: number) => x * 3)({ a: 1, b: 2 }), option.none)

Added in v2.5.0 v2.5.0中添加

partitionMapWithIndex   带索引的分区映射

Maps a ReadonlyRecord with a function returning an Either and partitions the resulting ReadonlyRecord into Lefts and Rights.
ReadonlyRecord 映射到返回 Either 的函数,并将生成的 ReadonlyRecord 划分为 LeftRight

Signature 签名

export declare function partitionMapWithIndex<K extends string, A, B, C>(
  f: (key: K, a: A) => Either<B, C>
): (fa: ReadonlyRecord<K, A>) => Separated<ReadonlyRecord<string, B>, ReadonlyRecord<string, C>>

Example 例子

import { partitionMapWithIndex } from 'fp-ts/ReadonlyRecord'
import { either } from 'fp-ts'

const f = (key: string, a: number) =>
  a >= 0 ? either.right(`${key} is >= 0 (${a})`) : either.left(`${key} is < 0 (${a})`)
assert.deepStrictEqual(partitionMapWithIndex(f)({ a: -1, b: 2, c: 123 }), {
  left: {
    a: 'a is < 0 (-1)',
  },
  right: {
    b: 'b is >= 0 (2)',
    c: 'c is >= 0 (123)',
  },
})

Added in v2.5.0 v2.5.0中添加

partitionWithIndex   带索引分区

Partition a ReadonlyRecord into two parts according to a predicate that takes a key and a value.
根据采用键和值的谓词将 ReadonlyRecord 分为两部分。

Signature 签名

export declare function partitionWithIndex<K extends string, A, B extends A>(
  refinementWithIndex: RefinementWithIndex<K, A, B>
): (fa: ReadonlyRecord<K, A>) => Separated<ReadonlyRecord<string, A>, ReadonlyRecord<string, B>>
export declare function partitionWithIndex<K extends string, A>(
  predicateWithIndex: PredicateWithIndex<K, A>
): <B extends A>(fb: ReadonlyRecord<K, B>) => Separated<ReadonlyRecord<string, B>, ReadonlyRecord<string, B>>
export declare function partitionWithIndex<K extends string, A>(
  predicateWithIndex: PredicateWithIndex<K, A>
): (fa: ReadonlyRecord<K, A>) => Separated<ReadonlyRecord<string, A>, ReadonlyRecord<string, A>>

Example 例子

import { partitionWithIndex } from 'fp-ts/ReadonlyRecord'

assert.deepStrictEqual(
  partitionWithIndex((key: string, a: number) => key.length <= 1 && a > 0)({ a: -1, b: 2, ccc: 7 }),
  {
    left: {
      a: -1,
      ccc: 7,
    },
    right: {
      b: 2,
    },
  }
)

Added in v2.5.0 v2.5.0中添加

pop   流行音乐

Delete a key and value from a ReadonlyRecord, returning the value as well as the subsequent ReadonlyRecord.
ReadonlyRecord 中删除键和值,返回该值以及后续的 ReadonlyRecord

Signature 签名

export declare function pop<K extends string>(
  k: K
): <KS extends string, A>(
  r: ReadonlyRecord<KS, A>
) => Option<readonly [A, ReadonlyRecord<string extends K ? string : Exclude<KS, K>, A>]>

Example 例子

import { pop } from 'fp-ts/ReadonlyRecord'
import { option } from 'fp-ts'

assert.deepStrictEqual(pop('a')({ a: 1, b: 2, c: 3 }), option.some([1, { b: 2, c: 3 }]))
assert.deepStrictEqual(pop('x')({ a: 1, b: 2, c: 3 }), option.none)

Added in v2.5.0 v2.5.0中添加

reduceRightWithIndex   减少右索引

Same as reduceWithIndex, but reduce starting from the right (i.e. in reverse order, from the last to the first entry according to the given Ord).
reduceWithIndex 相同,但从右侧开始减少(即按照相反的顺序,根据给定的 Ord 从最后一个条目到第一个条目)。

Signature 签名

export declare function reduceRightWithIndex(
  O: Ord<string>
): <K extends string, A, B>(b: B, f: (k: K, a: A, b: B) => B) => (fa: ReadonlyRecord<K, A>) => B
export declare function reduceRightWithIndex<K extends string, A, B>(
  b: B,
  f: (k: K, a: A, b: B) => B
): (fa: ReadonlyRecord<K, A>) => B

Example 例子

import { reduceRightWithIndex } from 'fp-ts/ReadonlyRecord'
import { Ord } from 'fp-ts/string'

const x = { c: 3, a: 'foo', b: false }
assert.deepStrictEqual(reduceRightWithIndex(Ord)([] as string[], (k, a, b) => [...b, `${k}-${a}`])(x), [
  'c-3',
  'b-false',
  'a-foo',
])

Added in v2.5.0 v2.5.0中添加

reduceWithIndex  减少索引

Reduces a ReadonlyRecord passing each key/value pair to the iterating function. Entries are processed in the order, sorted by key according to the given Ord.
减少将每个键/值对传递给迭代函数的 ReadonlyRecord 。条目按顺序处理,根据给定的 Ord 按键排序。

Signature 签名

export declare function reduceWithIndex(
  O: Ord<string>
): <K extends string, A, B>(b: B, f: (k: K, b: B, a: A) => B) => (fa: ReadonlyRecord<K, A>) => B
export declare function reduceWithIndex<K extends string, A, B>(
  b: B,
  f: (k: K, b: B, a: A) => B
): (fa: ReadonlyRecord<K, A>) => B

Example 例子

import { reduceWithIndex } from 'fp-ts/ReadonlyRecord'
import { Ord } from 'fp-ts/string'

const x = { c: 3, a: 'foo', b: false }
assert.deepStrictEqual(reduceWithIndex(Ord)([] as string[], (k, b, a) => [...b, `${k}-${a}`])(x), [
  'a-foo',
  'b-false',
  'c-3',
])

Added in v2.5.0 v2.5.0中添加

sequence   顺序

ReadonlyRecord sequencing, i.e., take a ReadonlyRecord in which elements are monads and return a monad of a ReadonlyRecord of the base types. The following example for instance shows sequencing a ReadonlyRecord<string, Option<number>> into an Option<ReadonlyRecord<string, number>>.
ReadonlyRecord 排序,即采用 ReadonlyRecord ,其中元素是 monad,并返回 ReadonlyRecord 基本类型的 monad。例如,以下示例显示将 ReadonlyRecord<string, Option<number>> 排序为 Option<ReadonlyRecord<string, number>>

sequence in ReadonlyRecord is equivalent to sequenceS in Apply.ts.
ReadonlyRecord 中的 sequence 相当于 Apply.ts 中的 sequenceS

Signature 签名

export declare function sequence<F extends URIS3>(
  F: Applicative3<F>
): <K extends string, R, E, A>(ta: ReadonlyRecord<K, Kind3<F, R, E, A>>) => Kind3<F, R, E, ReadonlyRecord<K, A>>
export declare function sequence<F extends URIS3, E>(
  F: Applicative3C<F, E>
): <K extends string, R, A>(ta: ReadonlyRecord<K, Kind3<F, R, E, A>>) => Kind3<F, R, E, ReadonlyRecord<K, A>>
export declare function sequence<F extends URIS2>(
  F: Applicative2<F>
): <K extends string, E, A>(ta: ReadonlyRecord<K, Kind2<F, E, A>>) => Kind2<F, E, ReadonlyRecord<K, A>>
export declare function sequence<F extends URIS2, E>(
  F: Applicative2C<F, E>
): <K extends string, A>(ta: ReadonlyRecord<K, Kind2<F, E, A>>) => Kind2<F, E, ReadonlyRecord<K, A>>
export declare function sequence<F extends URIS>(
  F: Applicative1<F>
): <K extends string, A>(ta: ReadonlyRecord<K, Kind<F, A>>) => Kind<F, ReadonlyRecord<K, A>>
export declare function sequence<F>(
  F: Applicative<F>
): <K extends string, A>(ta: ReadonlyRecord<K, HKT<F, A>>) => HKT<F, ReadonlyRecord<K, A>>

Example 例子

import { sequence } from 'fp-ts/ReadonlyRecord'
import { option } from 'fp-ts'
import { sequenceS } from 'fp-ts/Apply'

assert.deepStrictEqual(
  sequence(option.Applicative)({ a: option.some(1), b: option.some(2) }),
  option.some({ a: 1, b: 2 })
)
assert.deepStrictEqual(sequence(option.Applicative)({ a: option.some(1), b: option.none }), option.none)
assert.deepStrictEqual(
  sequence(option.Applicative)({ a: option.some(1), b: option.some(2) }),
  sequenceS(option.Applicative)({ a: option.some(1), b: option.some(2) })
)

Added in v2.5.0 v2.5.0中添加

size   尺寸

Calculate the number of key/value pairs in a ReadonlyRecord,
计算 ReadonlyRecord 中键/值对的数量,

Signature 签名

export declare const size: <A>(r: Readonly<Record<string, A>>) => number

Example 例子

import { size } from 'fp-ts/ReadonlyRecord'

assert.deepStrictEqual(size({ a: true, b: 2, c: 'three' }), 3)

Added in v2.5.0 v2.5.0中添加

some   一些

Test if at least one value in a ReadonlyRecord satisfies the predicate.
测试 ReadonlyRecord 中是否至少有一个值满足谓词。

Signature 签名

export declare function some<A>(predicate: (a: A) => boolean): (r: ReadonlyRecord<string, A>) => boolean

Example 例子

import { some } from 'fp-ts/ReadonlyRecord'

assert.deepStrictEqual(some((n: number) => n >= 0)({ a: 1, b: -2 }), true)
assert.deepStrictEqual(some((n: number) => n >= 0)({ a: -1, b: -2 }), false)

Added in v2.5.0 v2.5.0中添加

traverse   遍历

Signature 签名

export declare function traverse<F extends URIS4>(
  F: Applicative4<F>
): <S, R, E, A, B>(
  f: (a: A) => Kind4<F, S, R, E, B>
) => <K extends string>(ta: ReadonlyRecord<K, A>) => Kind4<F, S, R, E, ReadonlyRecord<K, B>>
export declare function traverse<F extends URIS3>(
  F: Applicative3<F>
): <R, E, A, B>(
  f: (a: A) => Kind3<F, R, E, B>
) => <K extends string>(ta: ReadonlyRecord<K, A>) => Kind3<F, R, E, ReadonlyRecord<K, B>>
export declare function traverse<F extends URIS3, E>(
  F: Applicative3C<F, E>
): <R, A, B>(
  f: (a: A) => Kind3<F, R, E, B>
) => <K extends string>(ta: ReadonlyRecord<K, A>) => Kind3<F, R, E, ReadonlyRecord<K, B>>
export declare function traverse<F extends URIS2>(
  F: Applicative2<F>
): <E, A, B>(
  f: (a: A) => Kind2<F, E, B>
) => <K extends string>(ta: ReadonlyRecord<K, A>) => Kind2<F, E, ReadonlyRecord<K, B>>
export declare function traverse<F extends URIS2, E>(
  F: Applicative2C<F, E>
): <A, B>(
  f: (a: A) => Kind2<F, E, B>
) => <K extends string>(ta: ReadonlyRecord<K, A>) => Kind2<F, E, ReadonlyRecord<K, B>>
export declare function traverse<F extends URIS>(
  F: Applicative1<F>
): <A, B>(f: (a: A) => Kind<F, B>) => <K extends string>(ta: ReadonlyRecord<K, A>) => Kind<F, ReadonlyRecord<K, B>>
export declare function traverse<F>(
  F: Applicative<F>
): <A, B>(f: (a: A) => HKT<F, B>) => <K extends string>(ta: ReadonlyRecord<K, A>) => HKT<F, ReadonlyRecord<K, B>>

Added in v2.5.0 v2.5.0中添加

traverseWithIndex   索引遍历

Signature 签名

export declare function traverseWithIndex<F extends URIS4>(
  F: Applicative4<F>
): <K extends string, S, R, E, A, B>(
  f: (k: K, a: A) => Kind4<F, S, R, E, B>
) => (ta: ReadonlyRecord<K, A>) => Kind4<F, S, R, E, ReadonlyRecord<K, B>>
export declare function traverseWithIndex<F extends URIS3>(
  F: Applicative3<F>
): <K extends string, R, E, A, B>(
  f: (k: K, a: A) => Kind3<F, R, E, B>
) => (ta: ReadonlyRecord<K, A>) => Kind3<F, R, E, ReadonlyRecord<K, B>>
export declare function traverseWithIndex<F extends URIS3, E>(
  F: Applicative3C<F, E>
): <K extends string, R, A, B>(
  f: (k: K, a: A) => Kind3<F, R, E, B>
) => (ta: ReadonlyRecord<K, A>) => Kind3<F, R, E, ReadonlyRecord<K, B>>
export declare function traverseWithIndex<F extends URIS2>(
  F: Applicative2<F>
): <K extends string, E, A, B>(
  f: (k: K, a: A) => Kind2<F, E, B>
) => (ta: ReadonlyRecord<K, A>) => Kind2<F, E, ReadonlyRecord<K, B>>
export declare function traverseWithIndex<F extends URIS2, E>(
  F: Applicative2C<F, E>
): <K extends string, A, B>(
  f: (k: K, a: A) => Kind2<F, E, B>
) => (ta: ReadonlyRecord<K, A>) => Kind2<F, E, ReadonlyRecord<K, B>>
export declare function traverseWithIndex<F extends URIS>(
  F: Applicative1<F>
): <K extends string, A, B>(
  f: (k: K, a: A) => Kind<F, B>
) => (ta: ReadonlyRecord<K, A>) => Kind<F, ReadonlyRecord<K, B>>
export declare function traverseWithIndex<F>(
  F: Applicative<F>
): <K extends string, A, B>(f: (k: K, a: A) => HKT<F, B>) => (ta: ReadonlyRecord<K, A>) => HKT<F, ReadonlyRecord<K, B>>

Added in v2.5.0 v2.5.0中添加

union   联盟

Union of two ReadonlyRecords. Takes two ReadonlyRecords and produces a ReadonlyRecord combining all the entries of the two inputs. It uses the concat function of the provided Magma to combine the elements with the same key.
两个 ReadonlyRecord 的并集。接受两个 ReadonlyRecord 并生成一个组合两个输入的所有条目的 ReadonlyRecord 。它使用提供的 Magmaconcat 函数来组合具有相同键的元素。

Signature 签名

export declare const union: <A>(
  M: Magma<A>
) => (second: Readonly<Record<string, A>>) => (first: Readonly<Record<string, A>>) => Readonly<Record<string, A>>

Example 例子

import { union } from 'fp-ts/ReadonlyRecord'
import { Magma } from 'fp-ts/Magma'

const m1: Magma<number> = { concat: (x: number, y: number) => x + y }
assert.deepStrictEqual(union(m1)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 4, b: 2, c: 3 })
const m2: Magma<number> = { concat: (x: number) => x }
assert.deepStrictEqual(union(m2)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 1, b: 2, c: 3 })

Added in v2.11.0 v2.11.0 中添加

updateAt   更新时间

Replace a key/value pair in a ReadonlyRecord.
替换 ReadonlyRecord 中的键/值对。

Signature 签名

export declare const updateAt: <A>(
  k: string,
  a: A
) => <K extends string>(r: Readonly<Record<K, A>>) => Option<Readonly<Record<K, A>>>

Example 例子

import { updateAt } from 'fp-ts/ReadonlyRecord'
import { option } from 'fp-ts'

assert.deepStrictEqual(updateAt('a', 3)({ a: 1, b: 2 }), option.some({ a: 3, b: 2 }))
assert.deepStrictEqual(updateAt('c', 3)({ a: 1, b: 2 }), option.none)

Added in v2.5.0 v2.5.0中添加

upsertAt   更新插入

Insert or replace a key/value pair in a ReadonlyRecord.
ReadonlyRecord 中插入或替换键/值对。

Signature 签名

export declare const upsertAt: <A>(k: string, a: A) => (r: Readonly<Record<string, A>>) => Readonly<Record<string, A>>

Example 例子

import { upsertAt } from 'fp-ts/ReadonlyRecord'

assert.deepStrictEqual(upsertAt('a', 5)({ a: 1, b: 2 }), { a: 5, b: 2 })
assert.deepStrictEqual(upsertAt('c', 5)({ a: 1, b: 2 }), { a: 1, b: 2, c: 5 })

Added in v2.10.0 v2.10.0 中添加

zone of death
死亡地带

FoldableWithIndex 可折叠带索引

Use getFoldableWithIndex instead. 请改用 getFoldableWithIndex

Signature 签名

export declare const FoldableWithIndex: FoldableWithIndex1<'ReadonlyRecord', string>

Added in v2.7.0 v2.7.0 中添加

Foldable 折叠式

Use getFoldable instead. 请改用 getFoldable

Signature 签名

export declare const Foldable: Foldable1<'ReadonlyRecord'>

Added in v2.7.0 v2.7.0 中添加

TraversableWithIndex 可遍历索引

Use getTraversableWithIndex instead. 请改用 getTraversableWithIndex

Signature 签名

export declare const TraversableWithIndex: TraversableWithIndex1<'ReadonlyRecord', string>

Added in v2.7.0 v2.7.0 中添加

Traversable 可穿越

Use getTraversable instead. 请改用 getTraversable

Signature 签名

export declare const Traversable: Traversable1<'ReadonlyRecord'>

Added in v2.7.0 v2.7.0 中添加

Witherable 枯萎的

Use getWitherable instead. 请改用 getWitherable

Signature 签名

export declare const Witherable: Witherable1<'ReadonlyRecord'>

Added in v2.7.0 v2.7.0 中添加

hasOwnProperty (function)
拥有自己的属性(函数)

Use has instead. 请改用 has

Signature 签名

export declare function hasOwnProperty<K extends string>(k: string, r: ReadonlyRecord<K, unknown>): k is K

Added in v2.5.0 v2.5.0中添加

insertAt 插入位置

Use upsertAt instead. 请改用 upsertAt

Signature 签名

export declare const insertAt: <A>(k: string, a: A) => (r: Readonly<Record<string, A>>) => Readonly<Record<string, A>>

Added in v2.5.0 v2.5.0中添加

readonlyRecord 只读记录

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass RR.Functor instead of RR.readonlyRecord (where RR is from import RR from 'fp-ts/ReadonlyRecord')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 RR.Functor 而不是 RR.readonlyRecord (其中 RR 来自 import RR from 'fp-ts/ReadonlyRecord'

Signature 签名

export declare const readonlyRecord: FunctorWithIndex1<'ReadonlyRecord', string> &
  FoldableWithIndex1<'ReadonlyRecord', string> &
  FilterableWithIndex1<'ReadonlyRecord', string> &
  TraversableWithIndex1<'ReadonlyRecord', string> &
  Witherable1<'ReadonlyRecord'>

Added in v2.5.0 v2.5.0中添加

ReadonlySet overview  只读集概述

Added in v2.5.0 v2.5.0中添加


Table of contents
目录


constructors  构造函数

singleton   单例

Create a set with one element
创建一个包含一个元素的集合

Signature 签名

export declare const singleton: <A>(a: A) => ReadonlySet<A>

Added in v2.5.0 v2.5.0中添加

conversions   转换

fromReadonlyArray   来自只读数组

Create a ReadonlySet from a ReadonlyArray
ReadonlyArray 创建 ReadonlySet

Signature 签名

export declare const fromReadonlyArray: <A>(E: Eq<A>) => (as: readonly A[]) => ReadonlySet<A>

Added in v2.10.0 v2.10.0 中添加

fromSet   来自集合

Signature 签名

export declare const fromSet: <A>(s: Set<A>) => ReadonlySet<A>

Added in v2.5.0 v2.5.0中添加

toReadonlyArray   到只读数组

Get a sorted ReadonlyArray of the values contained in a ReadonlySet.
获取 ReadonlySet 中包含的值的排序 ReadonlyArray

Signature 签名

export declare const toReadonlyArray: <A>(O: Ord<A>) => (set: ReadonlySet<A>) => readonly A[]

Added in v2.5.0 v2.5.0中添加

toSet   设置

Signature 签名

export declare function toSet<A>(s: ReadonlySet<A>): Set<A>

Added in v2.5.0 v2.5.0中添加

folding   折叠式的

reduceRight   减少右

Signature 签名

export declare const reduceRight: <A>(O: Ord<A>) => <B>(b: B, f: (a: A, b: B) => B) => (fa: ReadonlySet<A>) => B

Added in v2.11.0 v2.11.0 中添加

instances   实例

getDifferenceMagma   获取差异岩浆

Signature 签名

export declare const getDifferenceMagma: <A>(E: Eq<A>) => Magma<ReadonlySet<A>>

Added in v2.11.0 v2.11.0 中添加

getEq   得到方程

Signature 签名

export declare function getEq<A>(E: Eq<A>): Eq<ReadonlySet<A>>

Added in v2.5.0 v2.5.0中添加

getIntersectionSemigroup
获取交集半群

Signature 签名

export declare const getIntersectionSemigroup: <A>(E: Eq<A>) => Semigroup<ReadonlySet<A>>

Added in v2.5.0 v2.5.0中添加

getShow   获取显示

Signature 签名

export declare function getShow<A>(S: Show<A>): Show<ReadonlySet<A>>

Added in v2.5.0 v2.5.0中添加

getUnionMonoid  获取UnionMonoid

Signature 签名

export declare const getUnionMonoid: <A>(E: Eq<A>) => Monoid<ReadonlySet<A>>

Added in v2.5.0 v2.5.0中添加

getUnionSemigroup   获取UnionSemigroup

Signature 签名

export declare const getUnionSemigroup: <A>(E: Eq<A>) => Semigroup<ReadonlySet<A>>

Added in v2.11.0 v2.11.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'ReadonlySet'

Added in v2.11.0 v2.11.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.11.0 v2.11.0 中添加

utils   实用程序

chain  

Signature 签名

export declare function chain<B>(E: Eq<B>): <A>(f: (x: A) => ReadonlySet<B>) => (set: ReadonlySet<A>) => ReadonlySet<B>

Added in v2.5.0 v2.5.0中添加

compact   袖珍的

Signature 签名

export declare const compact: <A>(E: Eq<A>) => (fa: ReadonlySet<Option<A>>) => ReadonlySet<A>

Added in v2.5.0 v2.5.0中添加

difference   不同之处

Form the set difference (x - y)
形成设定差值( x - y )

Signature 签名

export declare function difference<A>(E: Eq<A>): {
  (that: ReadonlySet<A>): (me: ReadonlySet<A>) => ReadonlySet<A>
  (me: ReadonlySet<A>, that: ReadonlySet<A>): ReadonlySet<A>
}

Example 例子

import { difference } from 'fp-ts/ReadonlySet'
import * as N from 'fp-ts/number'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe(new Set([1, 2]), difference(N.Eq)(new Set([1, 3]))), new Set([2]))

Added in v2.5.0 v2.5.0中添加

elem   埃莱姆

Test if a value is a member of a set
测试一个值是否是集合的成员

Signature 签名

export declare function elem<A>(E: Eq<A>): {
  (a: A): (set: ReadonlySet<A>) => boolean
  (a: A, set: ReadonlySet<A>): boolean
}

Added in v2.5.0 v2.5.0中添加

empty   空的

Signature 签名

export declare const empty: ReadonlySet<never>

Added in v2.5.0 v2.5.0中添加

every   每一个

Signature 签名

export declare function every<A, B extends A>(refinement: Refinement<A, B>): Refinement<ReadonlySet<A>, ReadonlySet<B>>
export declare function every<A>(predicate: Predicate<A>): Predicate<ReadonlySet<A>>

Added in v2.5.0 v2.5.0中添加

filter   筛选

Signature 签名

export declare function filter<A, B extends A>(refinement: Refinement<A, B>): (set: ReadonlySet<A>) => ReadonlySet<B>
export declare function filter<A>(predicate: Predicate<A>): <B extends A>(set: ReadonlySet<B>) => ReadonlySet<B>
export declare function filter<A>(predicate: Predicate<A>): (set: ReadonlySet<A>) => ReadonlySet<A>

Added in v2.5.0 v2.5.0中添加

filterMap   过滤映射

Signature 签名

export declare function filterMap<B>(E: Eq<B>): <A>(f: (a: A) => Option<B>) => (fa: ReadonlySet<A>) => ReadonlySet<B>

Added in v2.5.0 v2.5.0中添加

foldMap   折叠图

Signature 签名

export declare function foldMap<A, M>(O: Ord<A>, M: Monoid<M>): (f: (a: A) => M) => (fa: ReadonlySet<A>) => M

Added in v2.5.0 v2.5.0中添加

insert   插入

Insert a value into a set
将值插入集合中

Signature 签名

export declare function insert<A>(E: Eq<A>): (a: A) => (set: ReadonlySet<A>) => ReadonlySet<A>

Added in v2.5.0 v2.5.0中添加

intersection   路口

The set of elements which are in both the first and second set
同时位于第一组和第二组中的元素集

Signature 签名

export declare function intersection<A>(E: Eq<A>): {
  (that: ReadonlySet<A>): (me: ReadonlySet<A>) => ReadonlySet<A>
  (me: ReadonlySet<A>, that: ReadonlySet<A>): ReadonlySet<A>
}

Added in v2.5.0 v2.5.0中添加

isEmpty   是空的

Test whether a ReadonlySet is empty.
测试 ReadonlySet 是否为空。

Signature 签名

export declare const isEmpty: <A>(set: ReadonlySet<A>) => boolean

Added in v2.10.0 v2.10.0 中添加

isSubset   是子集

true if and only if every element in the first set is an element of the second set
true 当且仅当第一个集合中的每个元素都是第二个集合中的元素

Signature 签名

export declare function isSubset<A>(E: Eq<A>): {
  (that: ReadonlySet<A>): (me: ReadonlySet<A>) => boolean
  (me: ReadonlySet<A>, that: ReadonlySet<A>): boolean
}

Added in v2.5.0 v2.5.0中添加

map   地图

Projects a Set through a function
通过函数投影集合

Signature 签名

export declare function map<B>(E: Eq<B>): <A>(f: (x: A) => B) => (set: ReadonlySet<A>) => ReadonlySet<B>

Added in v2.5.0 v2.5.0中添加

partition   分割

Signature 签名

export declare function partition<A, B extends A>(
  refinement: Refinement<A, B>
): (set: ReadonlySet<A>) => Separated<ReadonlySet<A>, ReadonlySet<B>>
export declare function partition<A>(
  predicate: Predicate<A>
): <B extends A>(set: ReadonlySet<B>) => Separated<ReadonlySet<B>, ReadonlySet<B>>
export declare function partition<A>(
  predicate: Predicate<A>
): (set: ReadonlySet<A>) => Separated<ReadonlySet<A>, ReadonlySet<A>>

Added in v2.5.0 v2.5.0中添加

partitionMap   分区图

Signature 签名

export declare function partitionMap<B, C>(
  EB: Eq<B>,
  EC: Eq<C>
): <A>(f: (a: A) => Either<B, C>) => (set: ReadonlySet<A>) => Separated<ReadonlySet<B>, ReadonlySet<C>>

Added in v2.5.0 v2.5.0中添加

reduce   减少

Signature 签名

export declare function reduce<A>(O: Ord<A>): <B>(b: B, f: (b: B, a: A) => B) => (fa: ReadonlySet<A>) => B

Added in v2.5.0 v2.5.0中添加

remove   消除

Delete a value from a set
从集合中删除一个值

Signature 签名

export declare const remove: <A>(E: Eq<A>) => (a: A) => (set: ReadonlySet<A>) => ReadonlySet<A>

Added in v2.5.0 v2.5.0中添加

separate   分离

Signature 签名

export declare function separate<E, A>(
  EE: Eq<E>,
  EA: Eq<A>
): (fa: ReadonlySet<Either<E, A>>) => Separated<ReadonlySet<E>, ReadonlySet<A>>

Added in v2.5.0 v2.5.0中添加

size   尺寸

Calculate the number of elements in a ReadonlySet.
计算 ReadonlySet 中的元素数量。

Signature 签名

export declare const size: <A>(set: ReadonlySet<A>) => number

Added in v2.10.0 v2.10.0 中添加

some   一些

Signature 签名

export declare const some: <A>(predicate: Predicate<A>) => (set: ReadonlySet<A>) => boolean

Added in v2.5.0 v2.5.0中添加

toggle   切换

Checks an element is a member of a set; If yes, removes the value from the set If no, inserts the value to the set
检查一个元素是否是集合的成员;如果是,则从集合中删除该值 如果否,则将该值插入到集合中

Signature 签名

export declare const toggle: <A>(E: Eq<A>) => (a: A) => (set: ReadonlySet<A>) => ReadonlySet<A>

Added in v2.10.0 v2.10.0 中添加

union   联盟

Form the union of two sets
形成两个集合的并集

Signature 签名

export declare function union<A>(E: Eq<A>): {
  (that: ReadonlySet<A>): (me: ReadonlySet<A>) => ReadonlySet<A>
  (me: ReadonlySet<A>, that: ReadonlySet<A>): ReadonlySet<A>
}

Added in v2.5.0 v2.5.0中添加

zone of death
死亡地带

fromArray 来自数组

Use fromReadonlyArray instead. 请改用 fromReadonlyArray

Signature 签名

export declare const fromArray: <A>(E: Eq<A>) => (as: readonly A[]) => ReadonlySet<A>

Added in v2.5.0 v2.5.0中添加

ReadonlyTuple overview  ReadonlyTuple 概述

Added in v2.5.0 v2.5.0中添加


Table of contents
目录


Extract   提炼

extract   提炼

Signature 签名

export declare const extract: <E, A>(wa: readonly [A, E]) => A

Added in v2.6.2 v2.6.2 中添加

error handling   错误处理

mapLeft   地图左

Alias of mapSnd.  mapSnd 的别名。

Signature 签名

export declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: readonly [A, E]) => readonly [A, G]

Added in v2.5.0 v2.5.0中添加

folding   折叠式的

foldMap   折叠图

Signature 签名

export declare const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <E>(fa: readonly [A, E]) => M

Added in v2.5.0 v2.5.0中添加

reduce   减少

Signature 签名

export declare const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <E>(fa: readonly [A, E]) => B

Added in v2.5.0 v2.5.0中添加

reduceRight   减少右

Signature 签名

export declare const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <E>(fa: readonly [A, E]) => B

Added in v2.5.0 v2.5.0中添加

instances   实例

Bifunctor   双函子

Signature 签名

export declare const Bifunctor: Bifunctor2<'ReadonlyTuple'>

Added in v2.7.0 v2.7.0 中添加

Comonad   科莫纳德

Signature 签名

export declare const Comonad: Comonad2<'ReadonlyTuple'>

Added in v2.7.0 v2.7.0 中添加

Foldable   折叠式

Signature 签名

export declare const Foldable: Foldable2<'ReadonlyTuple'>

Added in v2.7.0 v2.7.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor2<'ReadonlyTuple'>

Added in v2.7.0 v2.7.0 中添加

Semigroupoid   半群胚

Signature 签名

export declare const Semigroupoid: Semigroupoid2<'ReadonlyTuple'>

Added in v2.7.0 v2.7.0 中添加

Traversable   可穿越

Signature 签名

export declare const Traversable: Traversable2<'ReadonlyTuple'>

Added in v2.7.0 v2.7.0 中添加

getApplicative  获取应用程序

Signature 签名

export declare function getApplicative<M>(M: Monoid<M>): Applicative2C<URI, M>

Added in v2.5.0 v2.5.0中添加

getApply   获取申请

Signature 签名

export declare function getApply<S>(S: Semigroup<S>): Apply2C<URI, S>

Added in v2.5.0 v2.5.0中添加

getChain   获取链

Signature 签名

export declare function getChain<S>(S: Semigroup<S>): Chain2C<URI, S>

Added in v2.5.0 v2.5.0中添加

getChainRec   获取链记录

Signature 签名

export declare function getChainRec<M>(M: Monoid<M>): ChainRec2C<URI, M>

Added in v2.5.0 v2.5.0中添加

getMonad   获取单子

Signature 签名

export declare function getMonad<M>(M: Monoid<M>): Monad2C<URI, M>

Added in v2.5.0 v2.5.0中添加

mapping   映射

bimap   双图

Map a pair of functions over the two type arguments of the bifunctor.
将一对函数映射到双函子的两个类型参数上。

Signature 签名

export declare const bimap: <E, G, A, B>(
  mapSnd: (e: E) => G,
  mapFst: (a: A) => B
) => (fa: readonly [A, E]) => readonly [B, G]

Added in v2.5.0 v2.5.0中添加

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <E, B>(fab: readonly [(a: A) => B, E]) => readonly [B, E]

Added in v2.10.0 v2.10.0 中添加

map   地图

Alias of mapFst.  mapFst 的别名。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => <E>(fa: readonly [A, E]) => readonly [B, E]

Added in v2.5.0 v2.5.0中添加

mapFst   映射Fst

Map a function over the first component of a ReadonlyTuple.
将函数映射到 ReadonlyTuple 的第一个组件。

This is the map operation of the Functor instance.
这是 Functor 实例的 map 操作。

Signature 签名

export declare const mapFst: <A, B>(f: (a: A) => B) => <E>(fa: readonly [A, E]) => readonly [B, E]

Added in v2.10.0 v2.10.0 中添加

mapSnd   地图Snd

Map a function over the second component of a ReadonlyTuple.
将函数映射到 ReadonlyTuple 的第二个组件。

This is the mapLeft operation of the Bifunctor instance.
这是 Bifunctor 实例的 mapLeft 操作。

Signature 签名

export declare const mapSnd: <E, G>(f: (e: E) => G) => <A>(fa: readonly [A, E]) => readonly [A, G]

Added in v2.10.0 v2.10.0 中添加

traversing   穿越

sequence   顺序

Signature 签名

export declare const sequence: Sequence2<'ReadonlyTuple'>

Added in v2.6.3 v2.6.3 中添加

traverse   遍历

Signature 签名

export declare const traverse: PipeableTraverse2<'ReadonlyTuple'>

Added in v2.6.3 v2.6.3 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'ReadonlyTuple'

Added in v2.5.0 v2.5.0中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.5.0 v2.5.0中添加

utils   实用程序

compose   撰写

Signature 签名

export declare const compose: <A, B>(ab: readonly [B, A]) => <C>(bc: readonly [C, B]) => readonly [C, A]

Added in v2.5.0 v2.5.0中添加

duplicate   复制

Signature 签名

export declare const duplicate: <E, A>(wa: readonly [A, E]) => readonly [readonly [A, E], E]

Added in v2.5.0 v2.5.0中添加

extend   延长

Signature 签名

export declare const extend: <E, A, B>(f: (wa: readonly [A, E]) => B) => (wa: readonly [A, E]) => readonly [B, E]

Added in v2.5.0 v2.5.0中添加

fst   时间

Signature 签名

export declare function fst<A, E>(ea: readonly [A, E]): A

Added in v2.5.0 v2.5.0中添加

snd   斯德

Signature 签名

export declare function snd<A, E>(ea: readonly [A, E]): E

Added in v2.5.0 v2.5.0中添加

swap   交换

Signature 签名

export declare const swap: <A, E>(ea: readonly [A, E]) => readonly [E, A]

Added in v2.5.0 v2.5.0中添加

zone of death
死亡地带

readonlyTuple 只读元组

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass RT.Functor instead of RT.readonlyTuple (where RT is from import RT from 'fp-ts/ReadonlyTuple')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 RT.Functor 而不是 RT.readonlyTuple (其中 RT 来自 import RT from 'fp-ts/ReadonlyTuple'

Signature 签名

export declare const readonlyTuple: Semigroupoid2<'ReadonlyTuple'> &
  Bifunctor2<'ReadonlyTuple'> &
  Comonad2<'ReadonlyTuple'> &
  Foldable2<'ReadonlyTuple'> &
  Traversable2<'ReadonlyTuple'>

Added in v2.5.0 v2.5.0中添加

Record overview  记录概览

The Record module enables dealing with Typescript’s Record<K, T> type in a functional way, basically treating it as a Functor in T.
Record 模块能够以函数式方式处理 Typescript 的 Record<K, T> 类型,基本上将其视为 T 中的 Functor

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


conversions   转换

fromEntries   来自条目

Converts an Array of [key, value] tuples into a Record.
[key, value] 元组的 Array 转换为 Record

Signature 签名

export declare const fromEntries: <A>(fa: [string, A][]) => Record<string, A>

Example 例子

import { fromEntries } from 'fp-ts/Record'

assert.deepStrictEqual(
  fromEntries([
    ['a', 1],
    ['b', 2],
    ['a', 3],
  ]),
  { b: 2, a: 3 }
)

Added in v2.12.0 v2.12.0 中添加

toArray   到数组

Get a sorted Array of the key/value pairs contained in a Record. Sorted alphabetically by key.
获取 Record 中包含的键/值对的排序 Array 。按键按字母顺序排序。

Signature 签名

export declare const toArray: <K extends string, A>(r: Record<K, A>) => [K, A][]

Example 例子

import { toArray } from 'fp-ts/Record'

const x = { c: 3, a: 'foo', b: false }
assert.deepStrictEqual(toArray(x), [
  ['a', 'foo'],
  ['b', false],
  ['c', 3],
])

Added in v2.0.0 v2.0.0 中添加

toEntries   至条目

Alias of toArray.  toArray 的别名。

Signature 签名

export declare const toEntries: <K extends string, A>(r: Record<K, A>) => [K, A][]

Example 例子

import { toEntries } from 'fp-ts/Record'

assert.deepStrictEqual(toEntries({ b: 2, a: 1 }), [
  ['a', 1],
  ['b', 2],
])

Added in v2.12.0 v2.12.0 中添加

filtering   过滤

compact   袖珍的

Compact a Record of Options discarding the None values and keeping the Some values.
压缩 OptionRecord ,丢弃 None 值并保留 Some 值。

Signature 签名

export declare const compact: <A>(fa: Record<string, Option<A>>) => Record<string, A>

Example 例子

import { compact } from 'fp-ts/Record'
import { option } from 'fp-ts'

assert.deepStrictEqual(compact({ a: option.some('foo'), b: option.none, c: option.some('bar') }), {
  a: 'foo',
  c: 'bar',
})

Added in v2.0.0 v2.0.0 中添加

filter   筛选

Given a Predicate, it produces a new Record keeping only the entries with a value that satisfies the provided predicate.
给定一个 Predicate ,它会生成一个新的 Record ,仅保留具有满足所提供谓词的值的条目。

Signature 签名

export declare const filter: {
  <A, B extends A>(refinement: Refinement<A, B>): (fa: Record<string, A>) => Record<string, B>
  <A>(predicate: Predicate<A>): <B extends A>(fb: Record<string, B>) => Record<string, B>
  <A>(predicate: Predicate<A>): (fa: Record<string, A>) => Record<string, A>
}

Example 例子

import { filter } from 'fp-ts/Record'

assert.deepStrictEqual(filter((s: string) => s.length < 4)({ a: 'foo', b: 'bar', c: 'verylong' }), {
  a: 'foo',
  b: 'bar',
})

Added in v2.0.0 v2.0.0 中添加

filterMap   过滤映射

Maps a Record with an iterating function that returns an Option and it keeps only the Some values discarding the Nones.
使用返回 Option 的迭代函数映射 Record ,并且仅保留 Some 值并丢弃 None

Signature 签名

export declare const filterMap: <A, B>(f: (a: A) => Option<B>) => (fa: Record<string, A>) => Record<string, B>

Example 例子

import { filterMap } from 'fp-ts/Record'
import { option } from 'fp-ts'

const f = (s: string) => (s.length < 4 ? option.some(`${s} is short`) : option.none)
assert.deepStrictEqual(filterMap(f)({ a: 'foo', b: 'bar', c: 'verylong' }), {
  a: 'foo is short',
  b: 'bar is short',
})

Added in v2.0.0 v2.0.0 中添加

getWitherable   变得枯萎

Signature 签名

export declare const getWitherable: (O: Ord<string>) => Witherable1<URI>

Added in v2.11.0 v2.11.0 中添加

partition   分割

Partition a Record into two parts according to a Predicate.
根据 PredicateRecord 分成两部分。

Signature 签名

export declare const partition: {
  <A, B extends A>(refinement: Refinement<A, B>): (
    fa: Record<string, A>
  ) => Separated<Record<string, A>, Record<string, B>>
  <A>(predicate: Predicate<A>): <B extends A>(fb: Record<string, B>) => Separated<Record<string, B>, Record<string, B>>
  <A>(predicate: Predicate<A>): (fa: Record<string, A>) => Separated<Record<string, A>, Record<string, A>>
}

Example 例子

import { partition } from 'fp-ts/Record'

assert.deepStrictEqual(partition((s: string) => s.length < 4)({ a: 'foo', b: 'bar', c: 'verylong' }), {
  left: {
    c: 'verylong',
  },
  right: {
    a: 'foo',
    b: 'bar',
  },
})

Added in v2.0.0 v2.0.0 中添加

partitionMap   分区图

Maps a Record with a function returning an Either and partitions the resulting Record into Lefts and Rights.
Record 映射到返回 Either 的函数,并将生成的 Record 划分为 LeftRight

Signature 签名

export declare const partitionMap: <A, B, C>(
  f: (a: A) => Either<B, C>
) => (fa: Record<string, A>) => Separated<Record<string, B>, Record<string, C>>

Example 例子

import { partitionMap } from 'fp-ts/Record'
import { either } from 'fp-ts'

const f = (s: string) => (s.length < 4 ? either.right(`${s} is short`) : either.left(`${s} is not short`))
assert.deepStrictEqual(partitionMap(f)({ a: 'foo', b: 'bar', c: 'verylong' }), {
  left: {
    c: 'verylong is not short',
  },
  right: {
    a: 'foo is short',
    b: 'bar is short',
  },
})

Added in v2.0.0 v2.0.0 中添加

separate   分离

Separate a Record of Eithers into Lefts and Rights.
Either 中的 Record 分成 LeftRight

Signature 签名

export declare const separate: <A, B>(
  fa: Record<string, Either<A, B>>
) => Separated<Record<string, A>, Record<string, B>>

Example 例子

import { separate } from 'fp-ts/Record'
import { either } from 'fp-ts'

assert.deepStrictEqual(separate({ a: either.right('foo'), b: either.left('bar'), c: either.right('baz') }), {
  right: {
    a: 'foo',
    c: 'baz',
  },
  left: {
    b: 'bar',
  },
})

Added in v2.0.0 v2.0.0 中添加

wilt   枯萎

Signature 签名

export declare const wilt: PipeableWilt1<'Record'>

Added in v2.6.5 v2.6.5 中添加

wither   枯萎

Signature 签名

export declare const wither: PipeableWither1<'Record'>

Added in v2.6.5 v2.6.5 中添加

folding   折叠式的

foldMap   折叠图

Map and fold a Record. Map the Record passing each value to the iterating function. Then fold the results using the provided Monoid.
映射并折叠 Record 。映射 Record 将每个值传递给迭代函数。然后使用提供的 Monoid 折叠结果。

Signature 签名

export declare function foldMap(
  O: Ord<string>
): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: Record<string, A>) => M
export declare function foldMap<M>(M: Monoid<M>): <A>(f: (a: A) => M) => (fa: Record<string, A>) => M

Example 例子

import { foldMap } from 'fp-ts/Record'
import { Ord } from 'fp-ts/string'
import { Monoid } from 'fp-ts/Monoid'

const m: Monoid<string> = { empty: '', concat: (x: string, y: string) => (x ? `${x} -> ${y}` : `${y}`) }
const f = (a: number) => `-${a}-`
const x = { c: 3, a: 1, b: 2 }
assert.deepStrictEqual(foldMap(Ord)(m)(f)(x), '-1- -> -2- -> -3-')

Added in v2.0.0 v2.0.0 中添加

getFoldable   获取可折叠的

Produces a Foldable instance for a Record, using the provided Ord to sort the Record’s entries by key.
Record 生成一个 Foldable 实例,使用提供的 Ord 按键对 Record 的条目进行排序。

Signature 签名

export declare const getFoldable: (O: Ord<string>) => Foldable1<URI>

Added in v2.11.0 v2.11.0 中添加

getFoldableWithIndex   获取FoldableWithIndex

Produces a FoldableWithIndex1 instance for a Record, using the provided Ord to sort the Record’s entries by key.
Record 生成一个 FoldableWithIndex1 实例,使用提供的 Ord 按键对 Record 的条目进行排序。

Signature 签名

export declare const getFoldableWithIndex: (O: Ord<string>) => FoldableWithIndex1<URI, string>

Added in v2.11.0 v2.11.0 中添加

reduce   减少

Reduces a Record passing each value to the iterating function. Entries are processed in order, sorted by key according to the given Ord.
减少将每个值传递给迭代函数的 Record 。条目按顺序处理,根据给定的 Ord 按键排序。

Signature 签名

export declare function reduce(O: Ord<string>): <A, B>(b: B, f: (b: B, a: A) => B) => (fa: Record<string, A>) => B
export declare function reduce<A, B>(b: B, f: (b: B, a: A) => B): (fa: Record<string, A>) => B

Example 例子

import { reduce } from 'fp-ts/Record'
import { Ord } from 'fp-ts/string'

const x = { c: 3, a: 'foo', b: false }
assert.deepStrictEqual(reduce(Ord)([] as string[], (b, a) => [...b, `-${a}-`])(x), ['-foo-', '-false-', '-3-'])

Added in v2.0.0 v2.0.0 中添加

reduceRight   减少右

Same as reduce but entries are processed from the right, i.e. in reverse order, from the last to the first entry, according to the given Ord.
reduce 相同,但根据给定的 Ord ,从右侧开始处理条目,即以相反的顺序,从最后一个条目到第一个条目。

Signature 签名

export declare function reduceRight(O: Ord<string>): <A, B>(b: B, f: (a: A, b: B) => B) => (fa: Record<string, A>) => B
export declare function reduceRight<A, B>(b: B, f: (a: A, b: B) => B): (fa: Record<string, A>) => B

Example 例子

import { reduceRight } from 'fp-ts/Record'
import { Ord } from 'fp-ts/string'

const x = { c: 3, a: 'foo', b: false }
assert.deepStrictEqual(reduceRight(Ord)([] as string[], (a, b) => [...b, `-${a}-`])(x), ['-3-', '-false-', '-foo-'])

Added in v2.0.0 v2.0.0 中添加

instances   实例

Compactable   紧凑型

Signature 签名

export declare const Compactable: Compactable1<'Record'>

Added in v2.7.0 v2.7.0 中添加

Filterable   可过滤

Signature 签名

export declare const Filterable: Filterable1<'Record'>

Added in v2.7.0 v2.7.0 中添加

FilterableWithIndex   可通过索引过滤

Signature 签名

export declare const FilterableWithIndex: FilterableWithIndex1<'Record', string>

Added in v2.7.0 v2.7.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor1<'Record'>

Added in v2.7.0 v2.7.0 中添加

FunctorWithIndex   带索引的函子

Signature 签名

export declare const FunctorWithIndex: FunctorWithIndex1<'Record', string>

Added in v2.7.0 v2.7.0 中添加

getDifferenceMagma   获取差异岩浆

Produces a Magma with a concat function that combines two Records by making the difference.
使用 concat 函数生成 Magma ,该函数通过创建 difference 来组合两个 Record

Signature 签名

export declare const getDifferenceMagma: <A>() => Magma<Record<string, A>>

Example 例子

import { getDifferenceMagma, difference } from 'fp-ts/Record'
import { Magma } from 'fp-ts/Magma'

const r1 = { a: 3, c: 3 }
const r2 = { a: 1, b: 2 }
const m: Magma<Record<string, number>> = getDifferenceMagma<number>()
assert.deepStrictEqual(m.concat(r1, r2), difference(r2)(r1))
assert.deepStrictEqual(m.concat(r1, r2), { c: 3, b: 2 })

Added in v2.11.0 v2.11.0 中添加

getEq   得到方程

Given an Eq for the base type, it produces an Eq for a Record of that base type.
给定基本类型的 Eq ,它会为该基本类型的 Record 生成 Eq

Signature 签名

export declare const getEq: <K extends string, A>(E: Eq<A>) => Eq<Record<K, A>>

Example 例子

import { getEq } from 'fp-ts/Record'
import { string } from 'fp-ts'
import { Eq } from 'fp-ts/Eq'

const eq: Eq<Record<string, string>> = getEq(string.Eq)
assert.deepStrictEqual(eq.equals({ a: 'foo' }, { b: 'bar' }), false)
assert.deepStrictEqual(eq.equals({ a: 'foo' }, { a: 'foo' }), true)

Added in v2.0.0 v2.0.0 中添加

getIntersectionSemigroup
获取交集半群

Given a Semigroup in the base type, it produces a Semigroup in the Record of the base type. The resulting Semigroup concatenates two Records by intersection.
给定基类型中的 Semigroup ,它会在基类型的 Record 中生成 Semigroup 。生成的 Semigroup 通过 intersection 连接两个 Record

Signature 签名

export declare const getIntersectionSemigroup: <A>(S: Se.Semigroup<A>) => Se.Semigroup<Record<string, A>>

Example 例子

import { getIntersectionSemigroup } from 'fp-ts/Record'
import { Semigroup } from 'fp-ts/Semigroup'

const sNumber: Semigroup<number> = { concat: (x, y) => x - y }
const sRecord: Semigroup<Record<string, number>> = getIntersectionSemigroup(sNumber)
assert.deepStrictEqual(sRecord.concat({ a: 1, b: 2 }, { b: 3, c: 4 }), { b: -1 })

Added in v2.11.0 v2.11.0 中添加

getMonoid   获取Monoid

Returns a Monoid instance for Records, given a Semigroup instance for the base type. The Monoid makes the union of two Records comining the overlapping entries with the provided Semigroup.
给定基本类型的 Semigroup 实例,返回 Record s 的 Monoid 实例。 Monoid 将两个 Record 进行并集,将重叠条目与提供的 Semigroup 相结合。

Signature 签名

export declare const getMonoid: <K extends string, A>(S: Se.Semigroup<A>) => Monoid<Record<K, A>>

Example 例子

import { SemigroupSum } from 'fp-ts/number'
import { getMonoid } from 'fp-ts/Record'

const M = getMonoid(SemigroupSum)
assert.deepStrictEqual(M.concat({ foo: 123, bar: 234 }, { foo: 456, baz: 567 }), { foo: 579, bar: 234, baz: 567 })

Added in v2.0.0 v2.0.0 中添加

getShow   获取显示

Produces a Show for a Record, given a Show for the base type (a Show produces a human-readable representation of an instance). Record entries are sorted by key with the provided Ord.
Record 生成 Show ,给定基本类型 ShowShow 生成实例的人类可读表示)。 Record 条目使用提供的 Ord 按键排序。

Signature 签名

export declare function getShow(O: Ord<string>): <A>(S: Show<A>) => Show<Record<string, A>>
export declare function getShow<A>(S: Show<A>): Show<Record<string, A>>

Example 例子

import { getShow } from 'fp-ts/Record'
import { Show } from 'fp-ts/Show'
import { Ord } from 'fp-ts/string'

const sNumber: Show<number> = { show: (n: number) => `${n}` }
const sRecord: Show<Record<string, number>> = getShow(Ord)(sNumber)
assert.deepStrictEqual(sRecord.show({ b: 2, a: 1 }), '{ "a": 1, "b": 2 }')

Added in v2.0.0 v2.0.0 中添加

getUnionMonoid  获取UnionMonoid

Same as getMonoid. Returns a Monoid instance for Records given a Semigroup instance for the base type. The Monoid makes the union of two Records combining the entries that have the same key with the provided Semigroup.
getMonoid 相同。给定基本类型的 Semigroup 实例,返回 RecordMonoid 实例。 Monoid 将两个 Record 进行并集,将具有相同键的条目与提供的 Semigroup 组合起来。

Signature 签名

export declare const getUnionMonoid: <A>(S: Se.Semigroup<A>) => Monoid<Record<string, A>>

Example 例子

import { SemigroupSum } from 'fp-ts/number'
import { getUnionMonoid } from 'fp-ts/Record'

const M = getUnionMonoid(SemigroupSum)
assert.deepStrictEqual(M.concat({ foo: 123, bar: 234 }, { foo: 456, baz: 567 }), { foo: 579, bar: 234, baz: 567 })

Added in v2.11.0 v2.11.0 中添加

getUnionSemigroup   获取UnionSemigroup

Given a Semigroup in the base type, it produces a Semigroup in the Record of the base type. The resulting Semigroup concatenates two Records by union.
给定基类型中的 Semigroup ,它会在基类型的 Record 中生成 Semigroup 。生成的 Semigroup 通过 union 连接两个 Record

Signature 签名

export declare const getUnionSemigroup: <A>(S: Se.Semigroup<A>) => Se.Semigroup<Record<string, A>>

Example 例子

import { getUnionSemigroup } from 'fp-ts/Record'
import { Semigroup } from 'fp-ts/Semigroup'

const sNumber: Semigroup<number> = { concat: (x, y) => x - y }
const sRecord: Semigroup<Record<string, number>> = getUnionSemigroup(sNumber)
assert.deepStrictEqual(sRecord.concat({ a: 1, b: 2 }, { b: 3, c: 4 }), { a: 1, b: -1, c: 4 })

Added in v2.11.0 v2.11.0 中添加

mapping   映射

flap   皮瓣

Takes a value and a Record of functions and returns a Record by applying each function to the input value.
获取一个值和一个 Record 函数,并通过将每个函数应用于输入值来返回一个 Record

Signature 签名

export declare const flap: <A>(a: A) => <B>(fab: Record<string, (a: A) => B>) => Record<string, B>

Example 例子

import { flap } from 'fp-ts/Record'

const fab = { x: (n: number) => `${n} times 2`, y: (n: number) => `${n * 2}` }
assert.deepStrictEqual(flap(3)(fab), {
  x: '3 times 2',
  y: '6',
})

Added in v2.10.0 v2.10.0 中添加

map   地图

Map a Record passing the values to the iterating function.
映射 Record 将值传递给迭代函数。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => <K extends string>(fa: Record<K, A>) => Record<K, B>

Example 例子

import { map } from 'fp-ts/Record'

const f = (n: number) => `-${n}-`
assert.deepStrictEqual(map(f)({ a: 3, b: 5 }), { a: '-3-', b: '-5-' })

Added in v2.0.0 v2.0.0 中添加

traversing   穿越

getTraversable   获取可遍历的

Produces a Traversable instance for a Record, using the provided Ord to sort the Record’s entries by key.
Record 生成一个 Traversable 实例,使用提供的 Ord 按键对 Record 的条目进行排序。

Signature 签名

export declare const getTraversable: (O: Ord<string>) => Traversable1<URI>

Added in v2.11.0 v2.11.0 中添加

getTraversableWithIndex
getTraversableWithIndex

Produces a TraversableWithIndex instance for a Record, using the provided Ord to sort the Record’s entries by key.
Record 生成一个 TraversableWithIndex 实例,使用提供的 Ord 按键对 Record 的条目进行排序。

Signature 签名

export declare const getTraversableWithIndex: (O: Ord<string>) => TraversableWithIndex1<URI, string>

Added in v2.11.0 v2.11.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'Record'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

collect   收集

Map a Record into an Array. It passes each key/value pair to the iterating function and collects the results in an array, sorted alphabetically by the original key.
Record 映射到 Array 。它将每个键/值对传递给迭代函数,并将结果收集到一个数组中,并按原始键的字母顺序排序。

Signature 签名

export declare function collect(
  O: Ord<string>
): <K extends string, A, B>(f: (k: K, a: A) => B) => (r: Record<K, A>) => Array<B>
export declare function collect<K extends string, A, B>(f: (k: K, a: A) => B): (r: Record<K, A>) => Array<B>

Example 例子

import { collect } from 'fp-ts/Record'
import { Ord } from 'fp-ts/string'

const f = <A>(k: string, a: A) => `${k.toUpperCase()}-${a}`
const x = { c: 3, a: 'foo', b: false }
assert.deepStrictEqual(collect(Ord)(f)(x), ['A-foo', 'B-false', 'C-3'])

Added in v2.0.0 v2.0.0 中添加

deleteAt   删除处

Delete a key and value from a Record.
Record 中删除键和值。

Signature 签名

export declare function deleteAt<K extends string>(
  k: K
): <KS extends string, A>(r: Record<KS, A>) => Record<string extends K ? string : Exclude<KS, K>, A>

Example 例子

import { deleteAt } from 'fp-ts/Record'

assert.deepStrictEqual(deleteAt('a')({ a: 1, b: 2 }), { b: 2 })
assert.deepStrictEqual(deleteAt('c')({ a: 1, b: 2 }), { a: 1, b: 2 })

Added in v2.0.0 v2.0.0 中添加

difference   不同之处

Difference between two Records. Takes two Records and produces a Record composed by the entries of the two inputs, removing the entries with the same key in both inputs.
两个 Record 之间的差异。获取两个 Record 并生成由两个输入的条目组成的 Record ,删除两个输入中具有相同键的条目。

Signature 签名

export declare const difference: <A>(second: Record<string, A>) => (first: Record<string, A>) => Record<string, A>

Example 例子

import { difference } from 'fp-ts/Record'

assert.deepStrictEqual(difference({ a: 1 })({ a: 1, b: 2 }), { b: 2 })
assert.deepStrictEqual(difference({ a: 3 })({ a: 1, b: 2 }), { b: 2 })
assert.deepStrictEqual(difference({ a: 3, c: 3 })({ a: 1, b: 2 }), { b: 2, c: 3 })

Added in v2.11.0 v2.11.0 中添加

elem   埃莱姆

Given an Eq checks if a Record contains an entry with value equal to a provided value.
给定一个 Eq ,检查 Record 是否包含一个值等于所提供值的条目。

Signature 签名

export declare const elem: <A>(E: Eq<A>) => {
  (a: A): (fa: Record<string, A>) => boolean
  (a: A, fa: Record<string, A>): boolean
}

Example 例子

import { elem } from 'fp-ts/Record'
import { number } from 'fp-ts'

assert.deepStrictEqual(elem(number.Eq)(123, { foo: 123, bar: 234 }), true)
assert.deepStrictEqual(elem(number.Eq)(-7, { foo: 123, bar: 234 }), false)

Added in v2.0.0 v2.0.0 中添加

every   每一个

Test if every value in a Record satisfies the predicate.
测试 Record 中的每个值是否满足谓词。

Signature 签名

export declare const every: {
  <A, B extends A>(refinement: Refinement<A, B>): Refinement<Record<string, A>, Record<string, B>>
  <A>(predicate: Predicate<A>): Predicate<Record<string, A>>
}

Example 例子

import { every } from 'fp-ts/Record'

assert.deepStrictEqual(every((n: number) => n >= 0)({ a: 1, b: 2 }), true)
assert.deepStrictEqual(every((n: number) => n >= 0)({ a: 1, b: -1 }), false)

Added in v2.0.0 v2.0.0 中添加

filterMapWithIndex   带索引的过滤映射

Maps a Record with an iterating function that takes key and value and returns an Option, keeping only the Some values and discarding Nones.
使用迭代函数映射 Record ,该迭代函数接受键和值并返回 Option ,仅保留 Some 值并丢弃 None

Signature 签名

export declare const filterMapWithIndex: <K extends string, A, B>(
  f: (key: K, a: A) => Option<B>
) => (fa: Record<K, A>) => Record<string, B>

Example 例子

import { filterMapWithIndex } from 'fp-ts/Record'
import { option } from 'fp-ts'

const f = (key: string, a: number) => (a >= 0 ? option.some(`${key}${a}`) : option.none)
assert.deepStrictEqual(filterMapWithIndex(f)({ a: -1, b: 2, c: 3 }), {
  b: 'b2',
  c: 'c3',
})

Added in v2.0.0 v2.0.0 中添加

filterWithIndex   带索引的过滤器

Produce a new Record keeping only the entries that satisfy a predicate taking key and value as input.
生成一个新的 Record ,仅保留满足以键和值作为输入的谓词的条目。

Signature 签名

export declare function filterWithIndex<K extends string, A, B extends A>(
  refinementWithIndex: RefinementWithIndex<K, A, B>
): (fa: Record<K, A>) => Record<string, B>
export declare function filterWithIndex<K extends string, A>(
  predicateWithIndex: PredicateWithIndex<K, A>
): <B extends A>(fb: Record<K, B>) => Record<string, B>
export declare function filterWithIndex<K extends string, A>(
  predicateWithIndex: PredicateWithIndex<K, A>
): (fa: Record<K, A>) => Record<string, A>

Example 例子

import { filterWithIndex } from 'fp-ts/Record'

assert.deepStrictEqual(filterWithIndex((s: string, v: number) => s.length <= 1 && v > 0)({ a: 1, b: -2, ccc: 3 }), {
  a: 1,
})

Added in v2.0.0 v2.0.0 中添加

foldMapWithIndex   带索引的折叠地图

Map and fold a Record. Map the Record passing each key/value pair to the iterating function. Then fold the results using the provided Monoid.
映射并折叠 Record 。映射 Record ,将每个键/值对传递给迭代函数。然后使用提供的 Monoid 折叠结果。

Signature 签名

export declare function foldMapWithIndex(
  O: Ord<string>
): <M>(M: Monoid<M>) => <K extends string, A>(f: (k: K, a: A) => M) => (fa: Record<K, A>) => M
export declare function foldMapWithIndex<M>(
  M: Monoid<M>
): <K extends string, A>(f: (k: K, a: A) => M) => (fa: Record<K, A>) => M

Example 例子

import { foldMapWithIndex } from 'fp-ts/Record'
import { Ord } from 'fp-ts/string'
import { Monoid } from 'fp-ts/Monoid'

const m: Monoid<string> = { empty: '', concat: (x: string, y: string) => (x ? `${x} -> ${y}` : `${y}`) }
const f = (k: string, a: number) => `${k}-${a}`
const x = { c: 3, a: 1, b: 2 }
assert.deepStrictEqual(foldMapWithIndex(Ord)(m)(f)(x), 'a-1 -> b-2 -> c-3')

Added in v2.0.0 v2.0.0 中添加

fromFoldable   来自可折叠

Create a Record from a foldable collection of key/value pairs, using the specified Magma to combine values for duplicate keys.
从可折叠的键/值对集合创建 Record ,使用指定的 Magma 来组合重复键的值。

Signature 签名

export declare function fromFoldable<F extends URIS3, A>(
  M: Magma<A>,
  F: Foldable3<F>
): <R, E>(fka: Kind3<F, R, E, [string, A]>) => Record<string, A>
export declare function fromFoldable<F extends URIS2, A>(
  M: Magma<A>,
  F: Foldable2<F>
): <E>(fka: Kind2<F, E, [string, A]>) => Record<string, A>
export declare function fromFoldable<F extends URIS, A>(
  M: Magma<A>,
  F: Foldable1<F>
): (fka: Kind<F, [string, A]>) => Record<string, A>
export declare function fromFoldable<F, A>(
  M: Magma<A>,
  F: FoldableHKT<F>
): (fka: HKT<F, [string, A]>) => Record<string, A>

Added in v2.0.0 v2.0.0 中添加

fromFoldableMap   来自FoldableMap

Create a Record from a foldable collection using the specified functions to
使用指定的函数从可折叠集合创建 Record

  • map to key/value pairs
    映射到键/值对
  • combine values for duplicate keys.
    合并重复键的值。

Signature 签名

export declare function fromFoldableMap<F extends URIS3, B>(
  M: Magma<B>,
  F: Foldable3<F>
): <R, E, A>(fa: Kind3<F, R, E, A>, f: (a: A) => [string, B]) => Record<string, B>
export declare function fromFoldableMap<F extends URIS2, B>(
  M: Magma<B>,
  F: Foldable2<F>
): <E, A>(fa: Kind2<F, E, A>, f: (a: A) => [string, B]) => Record<string, B>
export declare function fromFoldableMap<F extends URIS, B>(
  M: Magma<B>,
  F: Foldable1<F>
): <A>(fa: Kind<F, A>, f: (a: A) => [string, B]) => Record<string, B>
export declare function fromFoldableMap<F, B>(
  M: Magma<B>,
  F: FoldableHKT<F>
): <A>(fa: HKT<F, A>, f: (a: A) => [string, B]) => Record<string, B>

Example 例子

import { last } from 'fp-ts/Semigroup'
import { Foldable, zip } from 'fp-ts/Array'
import { identity } from 'fp-ts/function'
import { fromFoldableMap } from 'fp-ts/Record'

export const zipObject = <K extends string, A>(keys: Array<K>, values: Array<A>): Record<K, A> =>
  fromFoldableMap(last<A>(), Foldable)(zip(keys, values), identity)

assert.deepStrictEqual(zipObject(['a', 'b'], [1, 2, 3]), { a: 1, b: 2 })

interface User {
  readonly id: string
  readonly name: string
}

const users: Array<User> = [
  { id: 'id1', name: 'name1' },
  { id: 'id2', name: 'name2' },
  { id: 'id1', name: 'name3' },
]

assert.deepStrictEqual(
  fromFoldableMap(last<User>(), Foldable)(users, (user) => [user.id, user]),
  {
    id1: { id: 'id1', name: 'name3' },
    id2: { id: 'id2', name: 'name2' },
  }
)

Added in v2.0.0 v2.0.0 中添加

has  

Test whether or not a key exists in a Record.
测试 Record 中是否存在某个键。

Note. This function is not pipeable because is a Refinement.
笔记。该函数不可通过管道传输,因为它是 Refinement

Signature 签名

export declare const has: <K extends string>(k: string, r: Record<K, unknown>) => k is K

Example 例子

import { has } from 'fp-ts/Record'

assert.deepStrictEqual(has('a', { a: 1, b: 2 }), true)
assert.deepStrictEqual(has('c', { a: 1, b: 2 }), false)

Added in v2.10.0 v2.10.0 中添加

intersection   路口

Intersection of two Records. Takes two Records and produces a Record combining only the entries of the two inputswith the same key. It uses the concat function of the provided Magma to combine the elements.
两个 Record 的交集。接受两个 Record 并生成一个 Record ,仅组合具有相同键的两个输入的条目。它使用提供的 Magmaconcat 函数来组合元素。

Signature 签名

export declare const intersection: <A>(
  M: Magma<A>
) => (second: Record<string, A>) => (first: Record<string, A>) => Record<string, A>

Example 例子

import { intersection } from 'fp-ts/Record'
import { Magma } from 'fp-ts/Magma'

const m1: Magma<number> = { concat: (x: number, y: number) => x + y }
assert.deepStrictEqual(intersection(m1)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 4 })
const m2: Magma<number> = { concat: (x: number) => x }
assert.deepStrictEqual(intersection(m2)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 1 })

Added in v2.11.0 v2.11.0 中添加

isEmpty   是空的

Test whether a Record is empty.
测试 Record 是否为空。

Signature 签名

export declare const isEmpty: <A>(r: Record<string, A>) => boolean

Example 例子

import { isEmpty } from 'fp-ts/Record'

assert.deepStrictEqual(isEmpty({}), true)
assert.deepStrictEqual(isEmpty({ a: 3 }), false)

Added in v2.0.0 v2.0.0 中添加

isSubrecord   是子记录

Test whether one Record contains all of the keys and values contained in another Record.
测试一个 Record 是否包含另一个 Record 中包含的所有键和值。

Signature 签名

export declare const isSubrecord: <A>(E: Eq<A>) => {
  (that: Record<string, A>): (me: Record<string, A>) => boolean
  (me: Record<string, A>, that: Record<string, A>): boolean
}

Example 例子

import { isSubrecord } from 'fp-ts/Record'
import { string } from 'fp-ts'

assert.deepStrictEqual(isSubrecord(string.Eq)({ a: 'foo', b: 'bar', c: 'baz' })({ a: 'foo', b: 'bar', c: 'baz' }), true)
assert.deepStrictEqual(isSubrecord(string.Eq)({ a: 'foo', b: 'bar', c: 'baz' })({ a: 'foo', c: 'baz' }), true)
assert.deepStrictEqual(
  isSubrecord(string.Eq)({ a: 'foo', b: 'bar', c: 'baz' })({ a: 'foo', b: 'not-bar', c: 'baz' }),
  false
)
assert.deepStrictEqual(isSubrecord(string.Eq)({ a: 'foo', b: 'bar' })({ a: 'foo', b: 'bar', c: 'baz' }), false)

Added in v2.0.0 v2.0.0 中添加

keys  

The keys of a Record, sorted alphabetically.
Record 的键,按字母顺序排序。

Signature 签名

export declare const keys: <K extends string>(r: Record<K, unknown>) => K[]

Example 例子

import { keys } from 'fp-ts/Record'

assert.deepStrictEqual(keys({ c: 1, a: 2, b: 3 }), ['a', 'b', 'c'])

Added in v2.0.0 v2.0.0 中添加

lookup   抬头

Lookup the value for a key in a Record.
Record 中查找键的值。

Signature 签名

export declare const lookup: {
  (k: string): <A>(r: Record<string, A>) => Option<A>
  <A>(k: string, r: Record<string, A>): Option<A>
}

Example 例子

import { lookup } from 'fp-ts/Record'
import { option } from 'fp-ts'

assert.deepStrictEqual(lookup('b')({ a: 'foo', b: 'bar' }), option.some('bar'))
assert.deepStrictEqual(lookup('c')({ a: 'foo', b: 'bar' }), option.none)

Added in v2.0.0 v2.0.0 中添加

mapWithIndex   带索引的映射

Map a Record passing the key/value pairs to the iterating function.
映射 Record 将键/值对传递给迭代函数。

Signature 签名

export declare const mapWithIndex: <K extends string, A, B>(f: (k: K, a: A) => B) => (fa: Record<K, A>) => Record<K, B>

Example 例子

import { mapWithIndex } from 'fp-ts/Record'

const f = (k: string, n: number) => `${k.toUpperCase()}-${n}`
assert.deepStrictEqual(mapWithIndex(f)({ a: 3, b: 5 }), { a: 'A-3', b: 'B-5' })

Added in v2.0.0 v2.0.0 中添加

modifyAt   修改处

Applies a mapping function to one spcific key/value pair in a Record.
将映射函数应用于 Record 中的一个特定键/值对。

Signature 签名

export declare const modifyAt: <A>(
  k: string,
  f: (a: A) => A
) => <K extends string>(r: Record<K, A>) => Option<Record<K, A>>

Example 例子

import { modifyAt } from 'fp-ts/Record'
import { option } from 'fp-ts'

assert.deepStrictEqual(modifyAt('a', (x: number) => x * 3)({ a: 1, b: 2 }), option.some({ a: 3, b: 2 }))
assert.deepStrictEqual(modifyAt('c', (x: number) => x * 3)({ a: 1, b: 2 }), option.none)

Added in v2.0.0 v2.0.0 中添加

partitionMapWithIndex   带索引的分区映射

Maps a Record with a function returning an Either and partitions the resulting Record into Lefts and Rights.
Record 映射到返回 Either 的函数,并将生成的 Record 划分为 LeftRight

Signature 签名

export declare const partitionMapWithIndex: <K extends string, A, B, C>(
  f: (key: K, a: A) => Either<B, C>
) => (fa: Record<K, A>) => Separated<Record<string, B>, Record<string, C>>

Example 例子

import { partitionMapWithIndex } from 'fp-ts/Record'
import { either } from 'fp-ts'

const f = (key: string, a: number) =>
  a >= 0 ? either.right(`${key} is >= 0 (${a})`) : either.left(`${key} is < 0 (${a})`)
assert.deepStrictEqual(partitionMapWithIndex(f)({ a: -1, b: 2, c: 123 }), {
  left: {
    a: 'a is < 0 (-1)',
  },
  right: {
    b: 'b is >= 0 (2)',
    c: 'c is >= 0 (123)',
  },
})

Added in v2.0.0 v2.0.0 中添加

partitionWithIndex   带索引分区

Partition a Record into two parts according to a predicate that takes a key and a value.
根据采用键和值的谓词将 Record 分为两部分。

Signature 签名

export declare function partitionWithIndex<K extends string, A, B extends A>(
  refinementWithIndex: RefinementWithIndex<K, A, B>
): (fa: Record<K, A>) => Separated<Record<string, A>, Record<string, B>>
export declare function partitionWithIndex<K extends string, A>(
  predicateWithIndex: PredicateWithIndex<K, A>
): <B extends A>(fb: Record<K, B>) => Separated<Record<string, B>, Record<string, B>>
export declare function partitionWithIndex<K extends string, A>(
  predicateWithIndex: PredicateWithIndex<K, A>
): (fa: Record<K, A>) => Separated<Record<string, A>, Record<string, A>>

Example 例子

import { partitionWithIndex } from 'fp-ts/Record'

assert.deepStrictEqual(
  partitionWithIndex((key: string, a: number) => key.length <= 1 && a > 0)({ a: -1, b: 2, ccc: 7 }),
  {
    left: {
      a: -1,
      ccc: 7,
    },
    right: {
      b: 2,
    },
  }
)

Added in v2.0.0 v2.0.0 中添加

pop   流行音乐

Delete a key and value from a Record, returning the value as well as the subsequent Record.
Record 中删除键和值,返回该值以及后续的 Record

Signature 签名

export declare function pop<K extends string>(
  k: K
): <KS extends string, A>(r: Record<KS, A>) => Option<[A, Record<string extends K ? string : Exclude<KS, K>, A>]>

Example 例子

import { pop } from 'fp-ts/Record'
import { option } from 'fp-ts'

assert.deepStrictEqual(pop('a')({ a: 1, b: 2, c: 3 }), option.some([1, { b: 2, c: 3 }]))
assert.deepStrictEqual(pop('x')({ a: 1, b: 2, c: 3 }), option.none)

Added in v2.0.0 v2.0.0 中添加

reduceRightWithIndex   减少右索引

Same as reduceWithIndex, but reduce starting from the right (i.e. in reverse order, from the last to the first entry according to the given Ord).
reduceWithIndex 相同,但从右侧开始减少(即按照相反的顺序,根据给定的 Ord 从最后一个条目到第一个条目)。

Signature 签名

export declare function reduceRightWithIndex(
  O: Ord<string>
): <K extends string, A, B>(b: B, f: (k: K, a: A, b: B) => B) => (fa: Record<K, A>) => B
export declare function reduceRightWithIndex<K extends string, A, B>(
  b: B,
  f: (k: K, a: A, b: B) => B
): (fa: Record<K, A>) => B

Example 例子

import { reduceRightWithIndex } from 'fp-ts/Record'
import { Ord } from 'fp-ts/string'

const x = { c: 3, a: 'foo', b: false }
assert.deepStrictEqual(reduceRightWithIndex(Ord)([] as string[], (k, a, b) => [...b, `${k}-${a}`])(x), [
  'c-3',
  'b-false',
  'a-foo',
])

Added in v2.0.0 v2.0.0 中添加

reduceWithIndex  减少索引

Reduces a Record passing each key/value pair to the iterating function. Entries are processed in the order, sorted by key according to the given Ord.
减少将每个键/值对传递给迭代函数的 Record 。条目按顺序处理,根据给定的 Ord 按键排序。

Signature 签名

export declare function reduceWithIndex(
  O: Ord<string>
): <K extends string, A, B>(b: B, f: (k: K, b: B, a: A) => B) => (fa: Record<K, A>) => B
export declare function reduceWithIndex<K extends string, A, B>(
  b: B,
  f: (k: K, b: B, a: A) => B
): (fa: Record<K, A>) => B

Example 例子

import { reduceWithIndex } from 'fp-ts/Record'
import { Ord } from 'fp-ts/string'

const x = { c: 3, a: 'foo', b: false }
assert.deepStrictEqual(reduceWithIndex(Ord)([] as string[], (k, b, a) => [...b, `${k}-${a}`])(x), [
  'a-foo',
  'b-false',
  'c-3',
])

Added in v2.0.0 v2.0.0 中添加

sequence   顺序

Record sequencing, i.e., take a Record in which elements are monads and return a monad of a Record of the base types. The following example for instance shows sequencing a Record<string, Option<number>> into an Option<Record<string, number>>.
Record 排序,即采用 Record ,其中元素是 monad,并返回 Record 基本类型的 monad。例如,以下示例显示将 Record<string, Option<number>> 排序为 Option<Record<string, number>>

sequence in Record is equivalent to sequenceS in Apply.ts.
Record 中的 sequence 相当于 Apply.ts 中的 sequenceS

Signature 签名

export declare function sequence<F extends URIS3>(
  F: Applicative3<F>
): <K extends string, R, E, A>(ta: Record<K, Kind3<F, R, E, A>>) => Kind3<F, R, E, Record<K, A>>
export declare function sequence<F extends URIS3, E>(
  F: Applicative3C<F, E>
): <K extends string, R, A>(ta: Record<K, Kind3<F, R, E, A>>) => Kind3<F, R, E, Record<K, A>>
export declare function sequence<F extends URIS2>(
  F: Applicative2<F>
): <K extends string, E, A>(ta: Record<K, Kind2<F, E, A>>) => Kind2<F, E, Record<K, A>>
export declare function sequence<F extends URIS2, E>(
  F: Applicative2C<F, E>
): <K extends string, A>(ta: Record<K, Kind2<F, E, A>>) => Kind2<F, E, Record<K, A>>
export declare function sequence<F extends URIS>(
  F: Applicative1<F>
): <K extends string, A>(ta: Record<K, Kind<F, A>>) => Kind<F, Record<K, A>>
export declare function sequence<F>(
  F: Applicative<F>
): <K extends string, A>(ta: Record<K, HKT<F, A>>) => HKT<F, Record<K, A>>

Example 例子

import { sequence } from 'fp-ts/Record'
import { option } from 'fp-ts'
import { sequenceS } from 'fp-ts/Apply'

assert.deepStrictEqual(
  sequence(option.Applicative)({ a: option.some(1), b: option.some(2) }),
  option.some({ a: 1, b: 2 })
)
assert.deepStrictEqual(sequence(option.Applicative)({ a: option.some(1), b: option.none }), option.none)
assert.deepStrictEqual(
  sequence(option.Applicative)({ a: option.some(1), b: option.some(2) }),
  sequenceS(option.Applicative)({ a: option.some(1), b: option.some(2) })
)

Added in v2.0.0 v2.0.0 中添加

singleton   单例

Create a Record with one key/value pair.
使用一个键/值对创建一个 Record

Signature 签名

export declare const singleton: <A>(k: string, a: A) => Record<string, A>

Example 例子

import { singleton } from 'fp-ts/Record'

assert.deepStrictEqual(singleton('a', 1), { a: 1 })

Added in v2.0.0 v2.0.0 中添加

size   尺寸

Calculate the number of key/value pairs in a Record.
计算 Record 中键/值对的数量。

Signature 签名

export declare const size: <A>(r: Record<string, A>) => number

Example 例子

import { size } from 'fp-ts/Record'

assert.deepStrictEqual(size({ a: true, b: 2, c: 'three' }), 3)

Added in v2.0.0 v2.0.0 中添加

some   一些

Test if at least one value in a Record satisfies the predicate.
测试 Record 中是否至少有一个值满足谓词。

Signature 签名

export declare const some: <A>(predicate: (a: A) => boolean) => (r: Record<string, A>) => boolean

Example 例子

import { some } from 'fp-ts/Record'

assert.deepStrictEqual(some((n: number) => n >= 0)({ a: 1, b: -2 }), true)
assert.deepStrictEqual(some((n: number) => n >= 0)({ a: -1, b: -2 }), false)

Added in v2.0.0 v2.0.0 中添加

toUnfoldable   至可展开

Unfolds a Record into a list of key/value pairs.
Record 展开为键/值对列表。

Given an Unfoldable class type U such as array or readonlyArray, it uses the unfold function to create an instance of U, providing an iterating function that iterates over each key/value pair in the record sorted alphabetically by key.
给定一个 Unfoldable 类类型 U ,例如 arrayreadonlyArray ,它使用 unfold 函数创建 U 的实例,提供迭代函数来迭代记录按字母顺序按键排序。

Signature 签名

export declare function toUnfoldable<F extends URIS>(
  U: Unfoldable1<F>
): <K extends string, A>(r: Record<K, A>) => Kind<F, [K, A]>
export declare function toUnfoldable<F>(U: Unfoldable<F>): <K extends string, A>(r: Record<K, A>) => HKT<F, [K, A]>

Example 例子

import { array, readonlyArray } from 'fp-ts'
import { toUnfoldable } from 'fp-ts/Record'

assert.deepStrictEqual(toUnfoldable(array)({ b: 2, a: 1 }), [
  ['a', 1],
  ['b', 2],
])
assert.deepStrictEqual(toUnfoldable(readonlyArray)({ b: 2, a: 1 }), [
  ['a', 1],
  ['b', 2],
])

Added in v2.0.0 v2.0.0 中添加

traverse   遍历

Signature 签名

export declare function traverse<F extends URIS4>(
  F: Applicative4<F>
): <S, R, E, A, B>(
  f: (a: A) => Kind4<F, S, R, E, B>
) => <K extends string>(ta: Record<K, A>) => Kind4<F, S, R, E, Record<K, B>>
export declare function traverse<F extends URIS3>(
  F: Applicative3<F>
): <R, E, A, B>(f: (a: A) => Kind3<F, R, E, B>) => <K extends string>(ta: Record<K, A>) => Kind3<F, R, E, Record<K, B>>
export declare function traverse<F extends URIS3, E>(
  F: Applicative3C<F, E>
): <R, A, B>(f: (a: A) => Kind3<F, R, E, B>) => <K extends string>(ta: Record<K, A>) => Kind3<F, R, E, Record<K, B>>
export declare function traverse<F extends URIS2>(
  F: Applicative2<F>
): <E, A, B>(f: (a: A) => Kind2<F, E, B>) => <K extends string>(ta: Record<K, A>) => Kind2<F, E, Record<K, B>>
export declare function traverse<F extends URIS2, E>(
  F: Applicative2C<F, E>
): <A, B>(f: (a: A) => Kind2<F, E, B>) => <K extends string>(ta: Record<K, A>) => Kind2<F, E, Record<K, B>>
export declare function traverse<F extends URIS>(
  F: Applicative1<F>
): <A, B>(f: (a: A) => Kind<F, B>) => <K extends string>(ta: Record<K, A>) => Kind<F, Record<K, B>>
export declare function traverse<F>(
  F: Applicative<F>
): <A, B>(f: (a: A) => HKT<F, B>) => <K extends string>(ta: Record<K, A>) => HKT<F, Record<K, B>>

Added in v2.0.0 v2.0.0 中添加

traverseWithIndex   索引遍历

Signature 签名

export declare function traverseWithIndex<F extends URIS4>(
  F: Applicative4<F>
): <K extends string, S, R, E, A, B>(
  f: (k: K, a: A) => Kind4<F, S, R, E, B>
) => (ta: Record<K, A>) => Kind4<F, S, R, E, Record<K, B>>
export declare function traverseWithIndex<F extends URIS3>(
  F: Applicative3<F>
): <K extends string, R, E, A, B>(
  f: (k: K, a: A) => Kind3<F, R, E, B>
) => (ta: Record<K, A>) => Kind3<F, R, E, Record<K, B>>
export declare function traverseWithIndex<F extends URIS3, E>(
  F: Applicative3C<F, E>
): <K extends string, R, A, B>(
  f: (k: K, a: A) => Kind3<F, R, E, B>
) => (ta: Record<K, A>) => Kind3<F, R, E, Record<K, B>>
export declare function traverseWithIndex<F extends URIS2>(
  F: Applicative2<F>
): <K extends string, E, A, B>(f: (k: K, a: A) => Kind2<F, E, B>) => (ta: Record<K, A>) => Kind2<F, E, Record<K, B>>
export declare function traverseWithIndex<F extends URIS2, E>(
  F: Applicative2C<F, E>
): <K extends string, A, B>(f: (k: K, a: A) => Kind2<F, E, B>) => (ta: Record<K, A>) => Kind2<F, E, Record<K, B>>
export declare function traverseWithIndex<F extends URIS>(
  F: Applicative1<F>
): <K extends string, A, B>(f: (k: K, a: A) => Kind<F, B>) => (ta: Record<K, A>) => Kind<F, Record<K, B>>
export declare function traverseWithIndex<F>(
  F: Applicative<F>
): <K extends string, A, B>(f: (k: K, a: A) => HKT<F, B>) => (ta: Record<K, A>) => HKT<F, Record<K, B>>

Added in v2.0.0 v2.0.0 中添加

union   联盟

Union of two Records. Takes two Records and produces a Record combining all the entries of the two inputs. It uses the concat function of the provided Magma to combine the elements with the same key.
两个 Record 的并集。接受两个 Record 并生成一个组合两个输入的所有条目的 Record 。它使用提供的 Magmaconcat 函数来组合具有相同键的元素。

Signature 签名

export declare const union: <A>(
  M: Magma<A>
) => (second: Record<string, A>) => (first: Record<string, A>) => Record<string, A>

Example 例子

import { union } from 'fp-ts/Record'
import { Magma } from 'fp-ts/Magma'

const m1: Magma<number> = { concat: (x: number, y: number) => x + y }
assert.deepStrictEqual(union(m1)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 4, b: 2, c: 3 })
const m2: Magma<number> = { concat: (x: number) => x }
assert.deepStrictEqual(union(m2)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 1, b: 2, c: 3 })

Added in v2.11.0 v2.11.0 中添加

updateAt   更新时间

Replace a key/value pair in a Record.
替换 Record 中的键/值对。

Signature 签名

export declare const updateAt: <A>(k: string, a: A) => <K extends string>(r: Record<K, A>) => Option<Record<K, A>>

Example 例子

import { updateAt } from 'fp-ts/Record'
import { option } from 'fp-ts'

assert.deepStrictEqual(updateAt('a', 3)({ a: 1, b: 2 }), option.some({ a: 3, b: 2 }))
assert.deepStrictEqual(updateAt('c', 3)({ a: 1, b: 2 }), option.none)

Added in v2.0.0 v2.0.0 中添加

upsertAt   更新插入

Insert or replace a key/value pair in a Record.
Record 中插入或替换键/值对。

Signature 签名

export declare const upsertAt: <A>(k: string, a: A) => (r: Record<string, A>) => Record<string, A>

Example 例子

import { upsertAt } from 'fp-ts/Record'

assert.deepStrictEqual(upsertAt('a', 5)({ a: 1, b: 2 }), { a: 5, b: 2 })
assert.deepStrictEqual(upsertAt('c', 5)({ a: 1, b: 2 }), { a: 1, b: 2, c: 5 })

Added in v2.10.0 v2.10.0 中添加

zone of death
死亡地带

FoldableWithIndex 可折叠带索引

Use getFoldableWithIndex instead. 请改用 getFoldableWithIndex

Signature 签名

export declare const FoldableWithIndex: FoldableWithIndex1<'Record', string>

Added in v2.7.0 v2.7.0 中添加

Foldable 折叠式

Use getFoldable instead. 请改用 getFoldable

Signature 签名

export declare const Foldable: Foldable1<'Record'>

Added in v2.7.0 v2.7.0 中添加

TraversableWithIndex 可遍历索引

Use the getTraversableWithIndex instead. 请改用 getTraversableWithIndex

Signature 签名

export declare const TraversableWithIndex: TraversableWithIndex1<'Record', string>

Added in v2.7.0 v2.7.0 中添加

Traversable 可穿越

Use getTraversable instead. 请改用 getTraversable

Signature 签名

export declare const Traversable: Traversable1<'Record'>

Added in v2.7.0 v2.7.0 中添加

Witherable 枯萎的

Use getWitherable instead. 请改用 getWitherable

Signature 签名

export declare const Witherable: Witherable1<'Record'>

Added in v2.7.0 v2.7.0 中添加

empty 空的

Use a new {} instead.
请改用新的 {}

Signature 签名

export declare const empty: Record<string, never>

Added in v2.0.0 v2.0.0 中添加

hasOwnProperty (function)
拥有自己的属性(函数)

Use has instead. 请改用 has

Signature 签名

export declare const hasOwnProperty: <K extends string>(k: string, r: Record<K, unknown>) => k is K

Added in v2.0.0 v2.0.0 中添加

insertAt 插入位置

Use upsertAt instead. 请改用 upsertAt

Signature 签名

export declare const insertAt: <A>(k: string, a: A) => (r: Record<string, A>) => Record<string, A>

Added in v2.0.0 v2.0.0 中添加

record 记录

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass R.Functor instead of R.record (where R is from import R from 'fp-ts/Record')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 R.Functor 而不是 R.record (其中 R 来自 import R from 'fp-ts/Record'

Signature 签名

export declare const record: FunctorWithIndex1<'Record', string> &
  FoldableWithIndex1<'Record', string> &
  FilterableWithIndex1<'Record', string> &
  TraversableWithIndex1<'Record', string> &
  Witherable1<'Record'>

Added in v2.0.0 v2.0.0 中添加

Refinement overview  细化概述

Added in v2.11.0 v2.11.0 中添加


Table of contents
目录


constructors  构造函数

id   ID

Signature 签名

export declare const id: <A>() => Refinement<A, A>

Added in v2.11.0 v2.11.0 中添加

lifting   起重

fromEitherK   来自EitherK

Signature 签名

export declare const fromEitherK: <A, B extends A>(getEither: (a: A) => Either<unknown, B>) => Refinement<A, B>

Added in v2.11.0 v2.11.0 中添加

fromOptionK   来自选项K

Returns a Refinement from a Option returning function. This function ensures that a Refinement definition is type-safe.
Option 返回函数返回 Refinement 。此函数确保 Refinement 定义是类型安全的。

Signature 签名

export declare const fromOptionK: <A, B extends A>(getOption: (a: A) => Option<B>) => Refinement<A, B>

Added in v2.11.0 v2.11.0 中添加

utils   实用程序

Refinement (interface)   细化(界面)

Signature 签名

export interface Refinement<A, B extends A> {
  (a: A): a is B
}

Added in v2.11.0 v2.11.0 中添加

and  

Signature 签名

export declare const and: <A, C extends A>(
  second: Refinement<A, C>
) => <B extends A>(first: Refinement<A, B>) => Refinement<A, B & C>

Added in v2.11.0 v2.11.0 中添加

compose   撰写

Signature 签名

export declare const compose: <A, B extends A, C extends B>(
  bc: Refinement<B, C>
) => (ab: Refinement<A, B>) => Refinement<A, C>

Added in v2.11.0 v2.11.0 中添加

not   不是

Signature 签名

export declare const not: <A, B extends A>(refinement: Refinement<A, B>) => Refinement<A, Exclude<A, B>>

Added in v2.11.0 v2.11.0 中添加

or   或者

Signature 签名

export declare const or: <A, C extends A>(
  second: Refinement<A, C>
) => <B extends A>(first: Refinement<A, B>) => Refinement<A, C | B>

Added in v2.11.0 v2.11.0 中添加

zero  

Signature 签名

export declare const zero: <A, B extends A>() => Refinement<A, B>

Added in v2.11.0 v2.11.0 中添加

Ring overview  戒指概述

The Ring class is for types that support addition, multiplication, and subtraction operations.
Ring 类适用于支持加法、乘法和减法运算的类型。

Instances must satisfy the following law in addition to the Semiring laws:
除了 Semiring 法则之外,实例还必须满足以下法则:

  • Additive inverse: a - a <-> (zero - a) + a <-> zero 加法逆: a - a <-> (zero - a) + a <-> zero

Adapted from https://github.com/purescript/purescript-prelude/blob/master/src/Data/Ring.purs
改编自https://github.com/purescript/purescript-prelude/blob/master/src/Data/Ring.purs

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Ring (interface)   环(接口)

Signature 签名

export interface Ring<A> extends Semiring<A> {
  readonly sub: (x: A, y: A) => A
}

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

negate   否定

negate x can be used as a shorthand for zero - x
negate x 可以用作 zero - x 的简写

Signature 签名

export declare const negate: <A>(R: Ring<A>) => (a: A) => A

Added in v2.0.0 v2.0.0 中添加

tuple   元组

Given a tuple of Rings returns a Ring for the tuple
给定一个 Ring s 的元组,返回该元组的 Ring

Signature 签名

export declare const tuple: <A extends readonly unknown[]>(
  ...rings: { [K in keyof A]: Ring<A[K]> }
) => Ring<Readonly<A>>

Example 例子

import { tuple } from 'fp-ts/Ring'
import * as N from 'fp-ts/number'

const R = tuple(N.Field, N.Field, N.Field)
assert.deepStrictEqual(R.add([1, 2, 3], [4, 5, 6]), [5, 7, 9])
assert.deepStrictEqual(R.mul([1, 2, 3], [4, 5, 6]), [4, 10, 18])
assert.deepStrictEqual(R.one, [1, 1, 1])
assert.deepStrictEqual(R.sub([1, 2, 3], [4, 5, 6]), [-3, -3, -3])
assert.deepStrictEqual(R.zero, [0, 0, 0])

Added in v2.10.0 v2.10.0 中添加

zone of death
死亡地带

getFunctionRing 获取功能环

Use getRing instead. 请改用 getRing

Signature 签名

export declare const getFunctionRing: <A, B>(R: Ring<B>) => Ring<(a: A) => B>

Added in v2.0.0 v2.0.0 中添加

getTupleRing 获取元组环

Use tuple instead. 请改用 tuple

Signature 签名

export declare const getTupleRing: <T extends readonly Ring<any>[]>(
  ...rings: T
) => Ring<{ [K in keyof T]: T[K] extends Ring<infer A> ? A : never }>

Added in v2.0.0 v2.0.0 中添加

Semigroup overview  半群概述

If a type A can form a Semigroup it has an associative binary operation.
如果类型 A 可以形成 Semigroup ,则它具有关联二元运算。

interface Semigroup<A> {
  readonly concat: (x: A, y: A) => A
}

Associativity means the following equality must hold for any choice of x, y, and z.
关联性意味着对于 xyz 的任何选择,以下等式都必须成立。

concat(x, concat(y, z)) = concat(concat(x, y), z)

A common example of a semigroup is the type string with the operation +.
半群的一个常见示例是类型 string 和运算 +

import { Semigroup } from 'fp-ts/Semigroup'

const semigroupString: Semigroup<string> = {
  concat: (x, y) => x + y,
}

const x = 'x'
const y = 'y'
const z = 'z'

semigroupString.concat(x, y) // 'xy'

semigroupString.concat(x, semigroupString.concat(y, z)) // 'xyz'

semigroupString.concat(semigroupString.concat(x, y), z) // 'xyz'

Adapted from https://typelevel.org/cats
改编自 https://typelevel.org/cats

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


constructors  构造函数

constant   持续的

Signature 签名

export declare const constant: <A>(a: A) => Semigroup<A>

Added in v2.10.0 v2.10.0 中添加

max   最大限度

Get a semigroup where concat will return the maximum, based on the provided order.
获取一个半群,其中 concat 将根据提供的顺序返回最大值。

Signature 签名

export declare const max: <A>(O: Or.Ord<A>) => Semigroup<A>

Example 例子

import * as N from 'fp-ts/number'
import * as S from 'fp-ts/Semigroup'

const S1 = S.max(N.Ord)

assert.deepStrictEqual(S1.concat(1, 2), 2)

Added in v2.10.0 v2.10.0 中添加

min   分钟

Get a semigroup where concat will return the minimum, based on the provided order.
获取一个半群,其中 concat 将根据提供的顺序返回最小值。

Signature 签名

export declare const min: <A>(O: Or.Ord<A>) => Semigroup<A>

Example 例子

import * as N from 'fp-ts/number'
import * as S from 'fp-ts/Semigroup'

const S1 = S.min(N.Ord)

assert.deepStrictEqual(S1.concat(1, 2), 1)

Added in v2.10.0 v2.10.0 中添加

instances   实例

first   第一的

Always return the first argument.
始终返回第一个参数。

Signature 签名

export declare const first: <A = never>() => Semigroup<A>

Example 例子

import * as S from 'fp-ts/Semigroup'

assert.deepStrictEqual(S.first<number>().concat(1, 2), 1)

Added in v2.10.0 v2.10.0 中添加

last   最后的

Always return the last argument.
始终返回最后一个参数。

Signature 签名

export declare const last: <A = never>() => Semigroup<A>

Example 例子

import * as S from 'fp-ts/Semigroup'

assert.deepStrictEqual(S.last<number>().concat(1, 2), 2)

Added in v2.10.0 v2.10.0 中添加

model   模型

Semigroup (interface)   半群(接口)

Signature 签名

export interface Semigroup<A> extends Magma<A> {}

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

concatAll   全部连接

Given a sequence of as, concat them and return the total.
给定一个 as 序列,将它们连接起来并返回总数。

If as is empty, return the provided startWith value.
如果 as 为空,则返回提供的 startWith 值。

Signature 签名

export declare const concatAll: <A>(S: Semigroup<A>) => (startWith: A) => (as: readonly A[]) => A

Example 例子

import { concatAll } from 'fp-ts/Semigroup'
import * as N from 'fp-ts/number'

const sum = concatAll(N.SemigroupSum)(0)

assert.deepStrictEqual(sum([1, 2, 3]), 6)
assert.deepStrictEqual(sum([]), 0)

Added in v2.10.0 v2.10.0 中添加

intercalate  

Between each pair of elements insert middle.
在每对元素之间插入 middle

Signature 签名

export declare const intercalate: <A>(middle: A) => (S: Semigroup<A>) => Semigroup<A>

Example 例子

import { intercalate } from 'fp-ts/Semigroup'
import * as S from 'fp-ts/string'
import { pipe } from 'fp-ts/function'

const S1 = pipe(S.Semigroup, intercalate(' + '))

assert.strictEqual(S1.concat('a', 'b'), 'a + b')

Added in v2.10.0 v2.10.0 中添加

reverse   撤销

The dual of a Semigroup, obtained by swapping the arguments of concat.
Semigroup 的对偶,通过交换 concat 的参数获得。

Signature 签名

export declare const reverse: <A>(S: Semigroup<A>) => Semigroup<A>

Example 例子

import { reverse } from 'fp-ts/Semigroup'
import * as S from 'fp-ts/string'

assert.deepStrictEqual(reverse(S.Semigroup).concat('a', 'b'), 'ba')

Added in v2.10.0 v2.10.0 中添加

struct   结构体

Given a struct of semigroups returns a semigroup for the struct.
给定一个半群结构,返回该结构的半群。

Signature 签名

export declare const struct: <A>(semigroups: { [K in keyof A]: Semigroup<A[K]> }) => Semigroup<{
  readonly [K in keyof A]: A[K]
}>

Example 例子

import { struct } from 'fp-ts/Semigroup'
import * as N from 'fp-ts/number'

interface Point {
  readonly x: number
  readonly y: number
}

const S = struct<Point>({
  x: N.SemigroupSum,
  y: N.SemigroupSum,
})

assert.deepStrictEqual(S.concat({ x: 1, y: 2 }, { x: 3, y: 4 }), { x: 4, y: 6 })

Added in v2.10.0 v2.10.0 中添加

tuple   元组

Given a tuple of semigroups returns a semigroup for the tuple.
给定一个半群元组,返回该元组的一个半群。

Signature 签名

export declare const tuple: <A extends readonly unknown[]>(
  ...semigroups: { [K in keyof A]: Semigroup<A[K]> }
) => Semigroup<Readonly<A>>

Example 例子

import { tuple } from 'fp-ts/Semigroup'
import * as B from 'fp-ts/boolean'
import * as N from 'fp-ts/number'
import * as S from 'fp-ts/string'

const S1 = tuple(S.Semigroup, N.SemigroupSum)
assert.deepStrictEqual(S1.concat(['a', 1], ['b', 2]), ['ab', 3])

const S2 = tuple(S.Semigroup, N.SemigroupSum, B.SemigroupAll)
assert.deepStrictEqual(S2.concat(['a', 1, true], ['b', 2, false]), ['ab', 3, false])

Added in v2.10.0 v2.10.0 中添加

zone of death
死亡地带

fold 折叠

Use concatAll instead. 请改用 concatAll

Signature 签名

export declare function fold<A>(S: Semigroup<A>): {
  (startWith: A): (as: ReadonlyArray<A>) => A
  (startWith: A, as: ReadonlyArray<A>): A
}

Added in v2.0.0 v2.0.0 中添加

getDualSemigroup 获取对偶半群

Use reverse instead. 请改用 reverse

Signature 签名

export declare const getDualSemigroup: <A>(S: Semigroup<A>) => Semigroup<A>

Added in v2.0.0 v2.0.0 中添加

getFirstSemigroup 获取第一个半群

Use first instead. 请改用 first

Signature 签名

export declare const getFirstSemigroup: <A = never>() => Semigroup<A>

Added in v2.0.0 v2.0.0 中添加

getFunctionSemigroup 获取函数半群

Use getSemigroup instead. 请改用 getSemigroup

Signature 签名

export declare const getFunctionSemigroup: <S>(S: Semigroup<S>) => <A = never>() => Semigroup<(a: A) => S>

Added in v2.0.0 v2.0.0 中添加

getIntercalateSemigroup 获取插值半群

Use intercalate instead. 请改用 intercalate

Signature 签名

export declare const getIntercalateSemigroup: <A>(middle: A) => (S: Semigroup<A>) => Semigroup<A>

Added in v2.5.0 v2.5.0中添加

getJoinSemigroup 获取加入半群

Use max instead. 请改用 max

Signature 签名

export declare const getJoinSemigroup: <A>(O: Or.Ord<A>) => Semigroup<A>

Added in v2.0.0 v2.0.0 中添加

getLastSemigroup 获取最后一个半群

Use last instead. 请改用 last

Signature 签名

export declare const getLastSemigroup: <A = never>() => Semigroup<A>

Added in v2.0.0 v2.0.0 中添加

getMeetSemigroup 获取MeetSemigroup

Use min instead. 请改用 min

Signature 签名

export declare const getMeetSemigroup: <A>(O: Or.Ord<A>) => Semigroup<A>

Added in v2.0.0 v2.0.0 中添加

getObjectSemigroup 获取对象半群

Use getAssignSemigroup instead. 请改用 getAssignSemigroup

Signature 签名

export declare const getObjectSemigroup: <A extends object = never>() => Semigroup<A>

Added in v2.0.0 v2.0.0 中添加

getStructSemigroup 获取结构半群

Use struct instead. 请改用 struct

Signature 签名

export declare const getStructSemigroup: <O extends Readonly<Record<string, any>>>(semigroups: {
  [K in keyof O]: Semigroup<O[K]>
}) => Semigroup<O>

Added in v2.0.0 v2.0.0 中添加

getTupleSemigroup 获取元组半群

Use tuple instead. 请改用 tuple

Signature 签名

export declare const getTupleSemigroup: <T extends readonly Semigroup<any>[]>(
  ...semigroups: T
) => Semigroup<{ [K in keyof T]: T[K] extends Semigroup<infer A> ? A : never }>

Added in v2.0.0 v2.0.0 中添加

semigroupAll 半群全部

Use SemigroupAll instead. 请改用 SemigroupAll

Signature 签名

export declare const semigroupAll: Semigroup<boolean>

Added in v2.0.0 v2.0.0 中添加

semigroupAny 半群任意

Use SemigroupAny instead. 请改用 SemigroupAny

Signature 签名

export declare const semigroupAny: Semigroup<boolean>

Added in v2.0.0 v2.0.0 中添加

semigroupProduct 半群积

Use SemigroupProduct instead. 请改用 SemigroupProduct

Signature 签名

export declare const semigroupProduct: Semigroup<number>

Added in v2.0.0 v2.0.0 中添加

semigroupString 半群字符串

Use Semigroup instead. 请改用 Semigroup

Signature 签名

export declare const semigroupString: Semigroup<string>

Added in v2.0.0 v2.0.0 中添加

semigroupSum 半群和

Use SemigroupSum instead. 请改用 SemigroupSum

Signature 签名

export declare const semigroupSum: Semigroup<number>

Added in v2.0.0 v2.0.0 中添加

semigroupVoid 半群空

Use void module instead. 请改用 void 模块。

Signature 签名

export declare const semigroupVoid: Semigroup<void>

Added in v2.0.0 v2.0.0 中添加

Semigroupoid overview  半群形概述

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Semigroupoid (interface)
半群曲面(接口)

Signature 签名

export interface Semigroupoid<F> {
  readonly URI: F
  readonly compose: <A, B, C>(bc: HKT2<F, B, C>, ab: HKT2<F, A, B>) => HKT2<F, A, C>
}

Added in v2.0.0 v2.0.0 中添加

Semigroupoid2 (interface)
Semigroupoid2(接口)

Signature 签名

export interface Semigroupoid2<F extends URIS2> {
  readonly URI: F
  readonly compose: <A, B, C>(ab: Kind2<F, B, C>, la: Kind2<F, A, B>) => Kind2<F, A, C>
}

Added in v2.0.0 v2.0.0 中添加

Semigroupoid2C (interface)
Semigroupoid2C(接口)

Signature 签名

export interface Semigroupoid2C<F extends URIS2, A> {
  readonly URI: F
  readonly _E: A
  readonly compose: <B, C>(ab: Kind2<F, B, C>, la: Kind2<F, A, B>) => Kind2<F, A, C>
}

Added in v2.0.0 v2.0.0 中添加

Semigroupoid3 (interface)
Semigroupoid3(接口)

Signature 签名

export interface Semigroupoid3<F extends URIS3> {
  readonly URI: F
  readonly compose: <R, A, B, C>(ab: Kind3<F, R, B, C>, la: Kind3<F, R, A, B>) => Kind3<F, R, A, C>
}

Added in v2.0.0 v2.0.0 中添加

Semigroupoid3C (interface)
Semigroupoid3C(接口)

Signature 签名

export interface Semigroupoid3C<F extends URIS3, A> {
  readonly URI: F
  readonly _E: A
  readonly compose: <R, B, C>(ab: Kind3<F, R, B, C>, la: Kind3<F, R, A, B>) => Kind3<F, R, A, C>
}

Added in v2.2.0 v2.2.0中添加

Semigroupoid4 (interface)
Semigroupoid4(接口)

Signature 签名

export interface Semigroupoid4<F extends URIS4> {
  readonly URI: F
  readonly compose: <S, R, A, B, C>(ab: Kind4<F, S, R, B, C>, la: Kind4<F, S, R, A, B>) => Kind4<F, S, R, A, C>
}

Added in v2.0.0 v2.0.0 中添加

Semiring overview  半环概述

The Semiring class is for types that support an addition and multiplication operation.
Semiring 类适用于支持加法和乘法运算的类型。

Instances must satisfy the following laws:
实例必须满足以下定律:

  • Commutative monoid under addition:
    加法下的交换幺半群:
    • Associativity: (a + b) + c <-> a + (b + c) 关联性: (a + b) + c <-> a + (b + c)
    • Identity: zero + a = a + zero <-> a 身份: zero + a = a + zero <-> a
    • Commutative: a + b <-> b + a 可交换: a + b <-> b + a
  • Monoid under multiplication:
    乘法下的幺半群:
    • Associativity: (a * b) * c <-> a * (b * c) 关联性: (a * b) * c <-> a * (b * c)
    • Identity: one * a <-> a * one <-> a 身份: one * a <-> a * one <-> a
  • Multiplication distributes over addition:
    乘法分布于加法:
    • Left distributivity: a * (b + c) <-> (a * b) + (a * c) 左分配率: a * (b + c) <-> (a * b) + (a * c)
    • Right distributivity: (a + b) * c <-> (a * c) + (b * c)
      右分布性: (a + b) * c <-> (a * c) + (b * c)
  • Annihilation: zero * a <-> a * zero <-> zero 湮灭: zero * a <-> a * zero <-> zero

Note: The number type is not fully law abiding members of this class hierarchy due to the potential for arithmetic overflows, and the presence of NaN and Infinity values. The behaviour is unspecified in these cases.
注意:由于存在算术溢出的可能性以及 NaNInfinity 值的存在, number 类型不是此类层次结构中完全守法的成员。在这些情况下,行为未指定。

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Semiring (interface)   半环(接口)

Signature 签名

export interface Semiring<A> {
  readonly add: (x: A, y: A) => A
  readonly zero: A
  readonly mul: (x: A, y: A) => A
  readonly one: A
}

Added in v2.0.0 v2.0.0 中添加

zone of death
死亡地带

getFunctionSemiring getFunctionSemiring

Use getSemiring instead. 请改用 getSemiring

Signature 签名

export declare const getFunctionSemiring: <A, B>(S: Semiring<B>) => Semiring<(a: A) => B>

Added in v2.0.0 v2.0.0 中添加

Separated overview  单独概览

interface Separated<E, A> {
  readonly left: E
  readonly right: A
}

Represents a result of separating a whole into two parts.
表示将整体分成两部分的结果。

Added in v2.10.0 v2.10.0 中添加


Table of contents
目录


constructors  构造函数

separated   分开

Signature 签名

export declare const separated: <E, A>(left: E, right: A) => Separated<E, A>

Added in v2.10.0 v2.10.0 中添加

error handling   错误处理

mapLeft   地图左

Map a function over the first type argument of a bifunctor.
将函数映射到双函子的第一个类型参数上。

Signature 签名

export declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: Separated<E, A>) => Separated<G, A>

Added in v2.10.0 v2.10.0 中添加

instances   实例

Bifunctor   双函子

Signature 签名

export declare const Bifunctor: Bifunctor2<'Separated'>

Added in v2.10.0 v2.10.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor2<'Separated'>

Added in v2.10.0 v2.10.0 中添加

mapping   映射

bimap   双图

Map a pair of functions over the two type arguments of the bifunctor.
将一对函数映射到双函子的两个类型参数上。

Signature 签名

export declare const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: Separated<E, A>) => Separated<G, B>

Added in v2.10.0 v2.10.0 中添加

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <E, B>(fab: Separated<E, (a: A) => B>) => Separated<E, B>

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => <E>(fa: Separated<E, A>) => Separated<E, B>

Added in v2.10.0 v2.10.0 中添加

model   模型

Separated (interface)   分离(接口)

A Separated type which holds left and right parts.
Separated 类型,包含 leftright 部分。

Signature 签名

export interface Separated<E, A> {
  readonly left: E
  readonly right: A
}

Added in v2.10.0 v2.10.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'Separated'

Added in v2.10.0 v2.10.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.10.0 v2.10.0 中添加

utils   实用程序

left  左边

Signature 签名

export declare const left: <E, A>(s: Separated<E, A>) => E

Added in v2.10.0 v2.10.0 中添加

Signature 签名

export declare const right: <E, A>(s: Separated<E, A>) => A

Added in v2.10.0 v2.10.0 中添加

Set overview  设置概览

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


constructors  构造函数

singleton   单例

Create a set with one element
创建一个包含一个元素的集合

Signature 签名

export declare const singleton: <A>(a: A) => Set<A>

Added in v2.0.0 v2.0.0 中添加

conversions   转换

fromArray   来自数组

Create a set from an array
从数组创建集合

Signature 签名

export declare const fromArray: <A>(E: Eq<A>) => (as: A[]) => Set<A>

Added in v2.0.0 v2.0.0 中添加

toArray   到数组

Get a sorted Array of the values contained in a Set.
获取 Set 中包含的值的排序 Array

Signature 签名

export declare const toArray: <A>(O: Ord<A>) => (set: Set<A>) => A[]

Added in v2.0.0 v2.0.0 中添加

folding   折叠式的

foldMap   折叠图

Signature 签名

export declare const foldMap: <A, M>(O: Ord<A>, M: Monoid<M>) => (f: (a: A) => M) => (fa: Set<A>) => M

Added in v2.0.0 v2.0.0 中添加

reduce   减少

Signature 签名

export declare const reduce: <A>(O: Ord<A>) => <B>(b: B, f: (b: B, a: A) => B) => (fa: Set<A>) => B

Added in v2.0.0 v2.0.0 中添加

reduceRight   减少右

Signature 签名

export declare const reduceRight: <A>(O: Ord<A>) => <B>(b: B, f: (a: A, b: B) => B) => (fa: Set<A>) => B

Added in v2.11.0 v2.11.0 中添加

instances   实例

getDifferenceMagma   获取差异岩浆

Signature 签名

export declare const getDifferenceMagma: <A>(E: Eq<A>) => Magma<Set<A>>

Added in v2.11.0 v2.11.0 中添加

getEq   得到方程

Signature 签名

export declare const getEq: <A>(E: Eq<A>) => Eq<Set<A>>

Added in v2.0.0 v2.0.0 中添加

getIntersectionSemigroup
获取交集半群

Signature 签名

export declare const getIntersectionSemigroup: <A>(E: Eq<A>) => Semigroup<Set<A>>

Added in v2.0.0 v2.0.0 中添加

getShow   获取显示

Signature 签名

export declare const getShow: <A>(S: Show<A>) => Show<Set<A>>

Added in v2.0.0 v2.0.0 中添加

getUnionMonoid  获取UnionMonoid

Signature 签名

export declare const getUnionMonoid: <A>(E: Eq<A>) => Monoid<Set<A>>

Added in v2.0.0 v2.0.0 中添加

getUnionSemigroup   获取UnionSemigroup

Signature 签名

export declare const getUnionSemigroup: <A>(E: Eq<A>) => Semigroup<Set<A>>

Added in v2.11.0 v2.11.0 中添加

utils   实用程序

chain  

Composes computations in sequence, using the return value of one computation to determine the next computation.
按顺序组成计算,使用一次计算的返回值来确定下一次计算。

Signature 签名

export declare function chain<B>(E: Eq<B>): <A>(f: (x: A) => Set<B>) => (set: Set<A>) => Set<B>

Added in v2.0.0 v2.0.0 中添加

compact   袖珍的

Signature 签名

export declare const compact: <A>(E: Eq<A>) => (fa: Set<Option<A>>) => Set<A>

Added in v2.0.0 v2.0.0 中添加

difference   不同之处

Form the set difference (x - y)
形成设定差值( x - y )

Signature 签名

export declare function difference<A>(E: Eq<A>): {
  (that: Set<A>): (me: Set<A>) => Set<A>
  (me: Set<A>, that: Set<A>): Set<A>
}

Example 例子

import { difference } from 'fp-ts/Set'
import * as N from 'fp-ts/number'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe(new Set([1, 2]), difference(N.Eq)(new Set([1, 3]))), new Set([2]))

Added in v2.0.0 v2.0.0 中添加

elem   埃莱姆

Test if a value is a member of a set
测试一个值是否是集合的成员

Signature 签名

export declare const elem: <A>(E: Eq<A>) => { (a: A): (set: Set<A>) => boolean; (a: A, set: Set<A>): boolean }

Added in v2.0.0 v2.0.0 中添加

empty   空的

Signature 签名

export declare const empty: Set<never>

Added in v2.0.0 v2.0.0 中添加

every   每一个

Signature 签名

export declare const every: {
  <A, B extends A>(refinement: Refinement<A, B>): Refinement<Set<A>, Set<B>>
  <A>(predicate: Predicate<A>): Predicate<Set<A>>
}

Added in v2.0.0 v2.0.0 中添加

filter   筛选

Signature 签名

export declare function filter<A, B extends A>(refinement: Refinement<A, B>): (set: Set<A>) => Set<B>
export declare function filter<A>(predicate: Predicate<A>): <B extends A>(set: Set<B>) => Set<B>
export declare function filter<A>(predicate: Predicate<A>): (set: Set<A>) => Set<A>

Added in v2.0.0 v2.0.0 中添加

filterMap   过滤映射

Signature 签名

export declare function filterMap<B>(E: Eq<B>): <A>(f: (a: A) => Option<B>) => (fa: Set<A>) => Set<B>

Added in v2.0.0 v2.0.0 中添加

insert   插入

Insert a value into a set
将值插入集合中

Signature 签名

export declare function insert<A>(E: Eq<A>): (a: A) => (set: Set<A>) => Set<A>

Added in v2.0.0 v2.0.0 中添加

intersection   路口

The set of elements which are in both the first and second set
同时位于第一组和第二组中的元素集

Signature 签名

export declare function intersection<A>(E: Eq<A>): {
  (that: Set<A>): (me: Set<A>) => Set<A>
  (me: Set<A>, that: Set<A>): Set<A>
}

Added in v2.0.0 v2.0.0 中添加

isEmpty   是空的

Test whether a Set is empty.
测试 Set 是否为空。

Signature 签名

export declare const isEmpty: <A>(set: Set<A>) => boolean

Added in v2.10.0 v2.10.0 中添加

isSubset   是子集

Signature 签名

export declare const isSubset: <A>(E: Eq<A>) => (that: Set<A>) => (me: Set<A>) => boolean

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare function map<B>(E: Eq<B>): <A>(f: (x: A) => B) => (set: Set<A>) => Set<B>

Added in v2.0.0 v2.0.0 中添加

partition   分割

Signature 签名

export declare function partition<A, B extends A>(
  refinement: Refinement<A, B>
): (set: Set<A>) => Separated<Set<A>, Set<B>>
export declare function partition<A>(predicate: Predicate<A>): <B extends A>(set: Set<B>) => Separated<Set<B>, Set<B>>
export declare function partition<A>(predicate: Predicate<A>): (set: Set<A>) => Separated<Set<A>, Set<A>>

Added in v2.0.0 v2.0.0 中添加

partitionMap   分区图

Signature 签名

export declare function partitionMap<B, C>(
  EB: Eq<B>,
  EC: Eq<C>
): <A>(f: (a: A) => Either<B, C>) => (set: Set<A>) => Separated<Set<B>, Set<C>>

Added in v2.0.0 v2.0.0 中添加

remove   消除

Delete a value from a set
从集合中删除一个值

Signature 签名

export declare const remove: <A>(E: Eq<A>) => (a: A) => (set: Set<A>) => Set<A>

Added in v2.0.0 v2.0.0 中添加

separate   分离

Signature 签名

export declare function separate<E, A>(EE: Eq<E>, EA: Eq<A>): (fa: Set<Either<E, A>>) => Separated<Set<E>, Set<A>>

Added in v2.0.0 v2.0.0 中添加

size   尺寸

Calculate the number of elements in a Set.
计算 Set 中的元素数量。

Signature 签名

export declare const size: <A>(set: Set<A>) => number

Added in v2.10.0 v2.10.0 中添加

some   一些

Signature 签名

export declare const some: <A>(predicate: Predicate<A>) => (set: Set<A>) => boolean

Added in v2.0.0 v2.0.0 中添加

toggle   切换

Checks an element is a member of a set; If yes, removes the value from the set If no, inserts the value to the set
检查一个元素是否是集合的成员;如果是,则从集合中删除该值 如果否,则将该值插入到集合中

Signature 签名

export declare const toggle: <A>(E: Eq<A>) => (a: A) => (set: Set<A>) => Set<A>

Added in v2.5.0 v2.5.0中添加

union   联盟

Form the union of two sets
形成两个集合的并集

Signature 签名

export declare function union<A>(E: Eq<A>): {
  (that: Set<A>): (me: Set<A>) => Set<A>
  (me: Set<A>, that: Set<A>): Set<A>
}

Added in v2.0.0 v2.0.0 中添加

zone of death
死亡地带

subset 子集

Use isSubset instead. 请改用 isSubset

Signature 签名

export declare const subset: <A>(E: Eq<A>) => {
  (that: Set<A>): (me: Set<A>) => boolean
  (me: Set<A>, that: Set<A>): boolean
}

Added in v2.0.0 v2.0.0 中添加

Show overview  显示概览

The Show type class represents those types which can be converted into a human-readable string representation.
Show 类型类表示可以转换为人类可读的 string 表示形式的类型。

While not required, it is recommended that for any expression x, the string show(x) be executable TypeScript code which evaluates to the same value as the expression x.
虽然不是必需的,但建议对于任何表达式 x ,字符串 show(x) 是可执行的 TypeScript 代码,其计算结果与表达式 x 的值相同。

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Show (interface)   显示(界面)

Signature 签名

export interface Show<A> {
  readonly show: (a: A) => string
}

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

struct   结构体

Signature 签名

export declare const struct: <A>(shows: { [K in keyof A]: Show<A[K]> }) => Show<{ readonly [K in keyof A]: A[K] }>

Added in v2.10.0 v2.10.0 中添加

tuple   元组

Signature 签名

export declare const tuple: <A extends readonly unknown[]>(
  ...shows: { [K in keyof A]: Show<A[K]> }
) => Show<Readonly<A>>

Added in v2.10.0 v2.10.0 中添加

zone of death
死亡地带

getStructShow 获取结构显示

Use struct instead. 请改用 struct

Signature 签名

export declare const getStructShow: <O extends Readonly<Record<string, any>>>(shows: {
  [K in keyof O]: Show<O[K]>
}) => Show<O>

Added in v2.0.0 v2.0.0 中添加

getTupleShow 获取元组显示

Use tuple instead. 请改用 tuple

Signature 签名

export declare const getTupleShow: <T extends readonly Show<any>[]>(
  ...shows: T
) => Show<{ [K in keyof T]: T[K] extends Show<infer A> ? A : never }>

Added in v2.0.0 v2.0.0 中添加

showBoolean 显示布尔值

Use Show instead. 请改用 Show

Signature 签名

export declare const showBoolean: Show<boolean>

Added in v2.0.0 v2.0.0 中添加

showNumber 显示号码

Use Show instead. 请改用 Show

Signature 签名

export declare const showNumber: Show<number>

Added in v2.0.0 v2.0.0 中添加

showString 显示字符串

Use Show instead. 请改用 Show

Signature 签名

export declare const showString: Show<string>

Added in v2.0.0 v2.0.0 中添加

State overview  州概况

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


combinators   组合器

tap   轻敲

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tap: {
  <S, A, _>(self: State<S, A>, f: (a: A) => State<S, _>): State<S, A>
  <A, S, _>(f: (a: A) => State<S, _>): (self: State<S, A>) => State<S, A>
}

Added in v2.15.0 v2.15.0 中添加

constructors  构造函数

get   得到

Get the current state
获取当前状态

Signature 签名

export declare const get: <S>() => State<S, S>

Added in v2.0.0 v2.0.0 中添加

gets   得到

Get a value which depends on the current state
获取取决于当前状态的值

Signature 签名

export declare const gets: <S, A>(f: (s: S) => A) => State<S, A>

Added in v2.0.0 v2.0.0 中添加

modify   调整

Modify the state by applying a function to the current state
通过将函数应用于当前状态来修改状态

Signature 签名

export declare const modify: <S>(f: (s: S) => S) => State<S, void>

Added in v2.0.0 v2.0.0 中添加

of  

Signature 签名

export declare const of: <S, A>(a: A) => State<S, A>

Added in v2.0.0 v2.0.0 中添加

put  

Set the state 设置状态

Signature 签名

export declare const put: <S>(s: S) => State<S, void>

Added in v2.0.0 v2.0.0 中添加

instances   实例

Applicative   适用性

Signature 签名

export declare const Applicative: Applicative2<'State'>

Added in v2.7.0 v2.7.0 中添加

Apply   申请

Signature 签名

export declare const Apply: Apply2<'State'>

Added in v2.10.0 v2.10.0 中添加

Chain  

Signature 签名

export declare const Chain: chainable.Chain2<'State'>

Added in v2.10.0 v2.10.0 中添加

FromState   来自州

Signature 签名

export declare const FromState: FromState2<'State'>

Added in v2.11.0 v2.11.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor2<'State'>

Added in v2.7.0 v2.7.0 中添加

Monad   单子

Signature 签名

export declare const Monad: Monad2<'State'>

Added in v2.7.0 v2.7.0 中添加

Pointed  

Signature 签名

export declare const Pointed: Pointed2<'State'>

Added in v2.10.0 v2.10.0 中添加

legacy   遗产

chain  

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chain: <S, A, B>(f: (a: A) => State<S, B>) => (ma: State<S, A>) => State<S, B>

Added in v2.0.0 v2.0.0 中添加

chainFirst   链优先

Alias of tap.  tap 的别名。

Signature 签名

export declare const chainFirst: <S, A, B>(f: (a: A) => State<S, B>) => (ma: State<S, A>) => State<S, A>

Added in v2.0.0 v2.0.0 中添加

mapping   映射

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <E, B>(fab: State<E, (a: A) => B>) => State<E, B>

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => <E>(fa: State<E, A>) => State<E, B>

Added in v2.0.0 v2.0.0 中添加

model   模型

State (interface)   状态(接口)

Signature 签名

export interface State<S, A> {
  (s: S): [A, S]
}

Added in v2.0.0 v2.0.0 中添加

sequencing   测序

flatMap   平面地图

Signature 签名

export declare const flatMap: {
  <A, S, B>(f: (a: A) => State<S, B>): (ma: State<S, A>) => State<S, B>
  <S, A, B>(ma: State<S, A>, f: (a: A) => State<S, B>): State<S, B>
}

Added in v2.14.0 v2.14.0 中添加

flatten   压扁

Signature 签名

export declare const flatten: <E, A>(mma: State<E, State<E, A>>) => State<E, A>

Added in v2.0.0 v2.0.0 中添加

traversing   穿越

sequenceArray   序列数组

Equivalent to ReadonlyArray#sequence(Applicative). 相当于 ReadonlyArray#sequence(Applicative)

Signature 签名

export declare const sequenceArray: <S, A>(arr: readonly State<S, A>[]) => State<S, readonly A[]>

Added in v2.9.0 v2.9.0中添加

traverseArray   遍历数组

Equivalent to ReadonlyArray#traverse(Applicative). 相当于 ReadonlyArray#traverse(Applicative)

Signature 签名

export declare const traverseArray: <A, S, B>(f: (a: A) => State<S, B>) => (as: readonly A[]) => State<S, readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseArrayWithIndex   带索引遍历数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseArrayWithIndex: <A, S, B>(
  f: (index: number, a: A) => State<S, B>
) => (as: readonly A[]) => State<S, readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseReadonlyArrayWithIndex
遍历带索引的只读数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseReadonlyArrayWithIndex: <A, S, B>(
  f: (index: number, a: A) => State<S, B>
) => (as: readonly A[]) => State<S, readonly B[]>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyNonEmptyArrayWithIndex
遍历ReadonlyNonEmptyArrayWithIndex

Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(Applicative). 相当于 ReadonlyNonEmptyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseReadonlyNonEmptyArrayWithIndex: <A, S, B>(
  f: (index: number, a: A) => State<S, B>
) => (as: ReadonlyNonEmptyArray<A>) => State<S, ReadonlyNonEmptyArray<B>>

Added in v2.11.0 v2.11.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'State'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

ap   美联社

Signature 签名

export declare const ap: <E, A>(fa: State<E, A>) => <B>(fab: State<E, (a: A) => B>) => State<E, B>

Added in v2.0.0 v2.0.0 中添加

apFirst   应用程序第一

Combine two effectful actions, keeping only the result of the first.
结合两个有效的操作,仅保留第一个操作的结果。

Signature 签名

export declare const apFirst: <E, B>(second: State<E, B>) => <A>(first: State<E, A>) => State<E, A>

Added in v2.0.0 v2.0.0 中添加

apS   apS

Signature 签名

export declare const apS: <N, A, E, B>(
  name: Exclude<N, keyof A>,
  fb: State<E, B>
) => (fa: State<E, A>) => State<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

apSecond   ap秒

Combine two effectful actions, keeping only the result of the second.
结合两个有效的操作,只保留第二个的结果。

Signature 签名

export declare const apSecond: <E, B>(second: State<E, B>) => <A>(first: State<E, A>) => State<E, B>

Added in v2.0.0 v2.0.0 中添加

bind   绑定

Signature 签名

export declare const bind: <N, A, E, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => State<E, B>
) => (ma: State<E, A>) => State<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bindTo   绑定到

Signature 签名

export declare const bindTo: <N>(name: N) => <E, A>(fa: State<E, A>) => State<E, { readonly [K in N]: A }>

Added in v2.8.0 v2.8.0 中添加

evaluate   评价

Run a computation in the State monad, discarding the final state
State monad 中运行计算,丢弃最终状态

Signature 签名

export declare const evaluate: <S>(s: S) => <A>(ma: State<S, A>) => A

Added in v2.8.0 v2.8.0 中添加

execute   执行

Run a computation in the State monad discarding the result
State monad 中运行计算并丢弃结果

Signature 签名

export declare const execute: <S>(s: S) => <A>(ma: State<S, A>) => S

Added in v2.8.0 v2.8.0 中添加

let  

Signature 签名

export declare const let: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => <E>(fa: State<E, A>) => State<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.13.0 v2.13.0 中添加

zone of death
死亡地带

evalState 评估状态

Use evaluate instead 使用 evaluate 代替

Signature 签名

export declare const evalState: <S, A>(ma: State<S, A>, s: S) => A

Added in v2.0.0 v2.0.0 中添加

execState 执行状态

Use execute instead 使用 execute 代替

Signature 签名

export declare const execState: <S, A>(ma: State<S, A>, s: S) => S

Added in v2.0.0 v2.0.0 中添加

state 状态

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass S.Functor instead of S.state (where S is from import S from 'fp-ts/State')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 S.Functor 而不是 S.state (其中 S 来自 import S from 'fp-ts/State'

Signature 签名

export declare const state: Monad2<'State'>

Added in v2.0.0 v2.0.0 中添加

StateReaderTaskEither overview
StateReaderTaskEither概述

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


combinators   组合器

tap   轻敲

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tap: {
  <S, R1, E1, A, R2, E2, _>(
    self: StateReaderTaskEither<S, R1, E1, A>,
    f: (a: A) => StateReaderTaskEither<S, R2, E2, _>
  ): StateReaderTaskEither<S, R1 & R2, E1 | E2, A>
  <A, S, R2, E2, _>(f: (a: A) => StateReaderTaskEither<S, R2, E2, _>): <R1, E1>(
    self: StateReaderTaskEither<S, R1, E1, A>
  ) => StateReaderTaskEither<S, R1 & R2, E2 | E1, A>
}

Added in v2.15.0 v2.15.0 中添加

tapEither   点击任一

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapEither: {
  <A, E2, _>(f: (a: A) => E.Either<E2, _>): <S, R1, E1>(
    self: StateReaderTaskEither<S, R1, E1, A>
  ) => StateReaderTaskEither<S, R1, E2 | E1, A>
  <S, R1, E1, A, E2, _>(self: StateReaderTaskEither<S, R1, E1, A>, f: (a: A) => E.Either<E2, _>): StateReaderTaskEither<
    S,
    R1,
    E1 | E2,
    A
  >
}

Added in v2.16.0 v2.16.0 中添加

tapIO   tapIO

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapIO: {
  <A, _>(f: (a: A) => IO<_>): <S, R, E>(self: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>
  <S, R, E, A, _>(self: StateReaderTaskEither<S, R, E, A>, f: (a: A) => IO<_>): StateReaderTaskEither<S, R, E, A>
}

Added in v2.16.0 v2.16.0 中添加

tapReader   点击阅读器

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapReader: {
  <A, R2, _>(f: (a: A) => R.Reader<R2, _>): <S, R1, E>(
    self: StateReaderTaskEither<S, R1, E, A>
  ) => StateReaderTaskEither<S, R1 & R2, E, A>
  <S, R1, E, A, R2, _>(self: StateReaderTaskEither<S, R1, E, A>, f: (a: A) => R.Reader<R2, _>): StateReaderTaskEither<
    S,
    R1 & R2,
    E,
    A
  >
}

Added in v2.16.0 v2.16.0 中添加

tapTask   点击任务

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapTask: {
  <A, _>(f: (a: A) => Task<_>): <S, R, E>(self: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>
  <S, R, E, A, _>(self: StateReaderTaskEither<S, R, E, A>, f: (a: A) => Task<_>): StateReaderTaskEither<S, R, E, A>
}

Added in v2.16.0 v2.16.0 中添加

constructors  构造函数

ask  

Reads the current context.
读取当前上下文。

Signature 签名

export declare const ask: <S, R, E = never>() => StateReaderTaskEither<S, R, E, R>

Added in v2.11.0 v2.11.0 中添加

asks  

Projects a value from the global context in a ReaderEither.
将全局上下文中的值投影到 ReaderEither 中。

Signature 签名

export declare const asks: <S, R, A, E = never>(f: (r: R) => A) => StateReaderTaskEither<S, R, E, A>

Added in v2.11.0 v2.11.0 中添加

asksStateReaderTaskEither
询问StateReaderTaskEither

Effectfully accesses the environment.
有效地访问环境。

Signature 签名

export declare const asksStateReaderTaskEither: <R, S, E, A>(
  f: (r: R) => StateReaderTaskEither<S, R, E, A>
) => StateReaderTaskEither<S, R, E, A>

Added in v2.11.0 v2.11.0 中添加

asksStateReaderTaskEitherW
询问StateReaderTaskEitherW

Less strict version of asksStateReaderTaskEither.
asksStateReaderTaskEither 的不太严格版本。

Signature 签名

export declare const asksStateReaderTaskEitherW: <R1, S, R2, E, A>(
  f: (r1: R1) => StateReaderTaskEither<S, R2, E, A>
) => StateReaderTaskEither<S, R1 & R2, E, A>

Added in v2.11.0 v2.11.0 中添加

fromReaderTaskEither  来自ReaderTaskEither

Signature 签名

export declare const fromReaderTaskEither: <R, E, A, S>(
  fa: RTE.ReaderTaskEither<R, E, A>
) => StateReaderTaskEither<S, R, E, A>

Added in v2.0.0 v2.0.0 中添加

get   得到

Get the current state
获取当前状态

Signature 签名

export declare const get: <S, R, E = never>() => StateReaderTaskEither<S, R, E, S>

Added in v2.0.0 v2.0.0 中添加

gets   得到

Get a value which depends on the current state
获取取决于当前状态的值

Signature 签名

export declare const gets: <S, R, E = never, A = never>(f: (s: S) => A) => StateReaderTaskEither<S, R, E, A>

Added in v2.0.0 v2.0.0 中添加

left  左边

Signature 签名

export declare const left: <S, R, E, A = never>(e: E) => StateReaderTaskEither<S, R, E, A>

Added in v2.0.0 v2.0.0 中添加

leftIO   左IO

Signature 签名

export declare function leftIO<S, R, E, A = never>(me: IO<E>): StateReaderTaskEither<S, R, E, A>

Added in v2.0.0 v2.0.0 中添加

leftReader   左读者

Signature 签名

export declare function leftReader<S, R, E, A = never>(me: Reader<R, E>): StateReaderTaskEither<S, R, E, A>

Added in v2.0.0 v2.0.0 中添加

leftState  左状态

Signature 签名

export declare const leftState: <S, R, E, A = never>(me: State<S, E>) => StateReaderTaskEither<S, R, E, A>

Added in v2.0.0 v2.0.0 中添加

leftTask   左任务

Signature 签名

export declare function leftTask<S, R, E, A = never>(me: Task<E>): StateReaderTaskEither<S, R, E, A>

Added in v2.0.0 v2.0.0 中添加

modify   调整

Modify the state by applying a function to the current state
通过将函数应用于当前状态来修改状态

Signature 签名

export declare const modify: <S, R, E = never>(f: Endomorphism<S>) => StateReaderTaskEither<S, R, E, void>

Added in v2.0.0 v2.0.0 中添加

of  

Signature 签名

export declare const of: <S, R = unknown, E = never, A = never>(a: A) => StateReaderTaskEither<S, R, E, A>

Added in v2.7.0 v2.7.0 中添加

put  

Set the state 设置状态

Signature 签名

export declare const put: <S, R, E = never>(s: S) => StateReaderTaskEither<S, R, E, void>

Added in v2.0.0 v2.0.0 中添加

Signature 签名

export declare const right: <S, R, E = never, A = never>(a: A) => StateReaderTaskEither<S, R, E, A>

Added in v2.0.0 v2.0.0 中添加

rightIO   右IO

Signature 签名

export declare function rightIO<S, R, E = never, A = never>(ma: IO<A>): StateReaderTaskEither<S, R, E, A>

Added in v2.0.0 v2.0.0 中添加

rightReader   右阅读器

Signature 签名

export declare function rightReader<S, R, E = never, A = never>(ma: Reader<R, A>): StateReaderTaskEither<S, R, E, A>

Added in v2.0.0 v2.0.0 中添加

rightState  正确的状态

Signature 签名

export declare const rightState: <S, R, E = never, A = never>(ma: State<S, A>) => StateReaderTaskEither<S, R, E, A>

Added in v2.0.0 v2.0.0 中添加

rightTask   正确的任务

Signature 签名

export declare function rightTask<S, R, E = never, A = never>(ma: Task<A>): StateReaderTaskEither<S, R, E, A>

Added in v2.0.0 v2.0.0 中添加

conversions   转换

fromEither   来自任一

Signature 签名

export declare const fromEither: <E, A, S, R = unknown>(fa: E.Either<E, A>) => StateReaderTaskEither<S, R, E, A>

Added in v2.0.0 v2.0.0 中添加

fromIO   来自IO

Signature 签名

export declare const fromIO: <A, S, R = unknown, E = never>(fa: IO<A>) => StateReaderTaskEither<S, R, E, A>

Added in v2.7.0 v2.7.0 中添加

fromIOEither   来自IOEither

Signature 签名

export declare const fromIOEither: <E, A, S, R = unknown>(fa: IOEither<E, A>) => StateReaderTaskEither<S, R, E, A>

Added in v2.0.0 v2.0.0 中添加

fromOption   来自选项

Signature 签名

export declare const fromOption: <E>(
  onNone: LazyArg<E>
) => <A, S, R = unknown>(fa: Option<A>) => StateReaderTaskEither<S, R, E, A>

Added in v2.0.0 v2.0.0 中添加

fromReader   来自读者

Signature 签名

export declare const fromReader: <R, A, S, E = never>(fa: R.Reader<R, A>) => StateReaderTaskEither<S, R, E, A>

Added in v2.11.0 v2.11.0 中添加

fromReaderEither   来自读者要么

Signature 签名

export declare const fromReaderEither: <R, E, A, S>(fa: ReaderEither<R, E, A>) => StateReaderTaskEither<S, R, E, A>

Added in v2.0.0 v2.0.0 中添加

fromState   来自州

Signature 签名

export declare const fromState: <S, A, R = unknown, E = never>(fa: State<S, A>) => StateReaderTaskEither<S, R, E, A>

Added in v2.10.0 v2.10.0 中添加

fromTask   来自任务

Signature 签名

export declare const fromTask: <A, S, R = unknown, E = never>(fa: Task<A>) => StateReaderTaskEither<S, R, E, A>

Added in v2.7.0 v2.7.0 中添加

fromTaskEither   来自任务要么

Signature 签名

export declare const fromTaskEither: <E, A, S, R = unknown>(fa: TaskEither<E, A>) => StateReaderTaskEither<S, R, E, A>

Added in v2.0.0 v2.0.0 中添加

do notation   做记号

apSW   apSW

Less strict version of apS.
apS 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const apSW: <A, N extends string, S, R2, E2, B>(
  name: Exclude<N, keyof A>,
  fb: StateReaderTaskEither<S, R2, E2, B>
) => <R1, E1>(
  fa: StateReaderTaskEither<S, R1, E1, A>
) => StateReaderTaskEither<S, R1 & R2, E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

error handling   错误处理

alt   替代

Identifies an associative operation on a type constructor. It is similar to Semigroup, except that it applies to types of kind * -> *.
标识类型构造函数上的关联操作。它与 Semigroup 类似,但它适用于 * -> * 类型。

Signature 签名

export declare const alt: <S, R, E, A>(
  that: LazyArg<StateReaderTaskEither<S, R, E, A>>
) => (fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>

Added in v2.6.2 v2.6.2 中添加

altW   替代W

Less strict version of alt.
alt 的不太严格版本。

The W suffix (short for Widening) means that the environment, the error and the return types will be merged.
W 后缀(Widening 的缩写)意味着环境、错误和返回类型将被合并。

Signature 签名

export declare const altW: <S, R2, E2, B>(
  that: () => StateReaderTaskEither<S, R2, E2, B>
) => <R1, E1, A>(fa: StateReaderTaskEither<S, R1, E1, A>) => StateReaderTaskEither<S, R1 & R2, E2, B | A>

Added in v2.9.0 v2.9.0中添加

mapLeft   地图左

Map a function over the third type argument of a bifunctor.
将函数映射到双函子的第三个类型参数上。

Signature 签名

export declare const mapLeft: <E, G>(
  f: (e: E) => G
) => <S, R, A>(fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, G, A>

Added in v2.6.2 v2.6.2 中添加

filtering   过滤

filterOrElse  过滤器或者其他

Signature 签名

export declare const filterOrElse: {
  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <S, R>(
    ma: StateReaderTaskEither<S, R, E, A>
  ) => StateReaderTaskEither<S, R, E, B>
  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R, B extends A>(
    mb: StateReaderTaskEither<S, R, E, B>
  ) => StateReaderTaskEither<S, R, E, B>
  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R>(
    ma: StateReaderTaskEither<S, R, E, A>
  ) => StateReaderTaskEither<S, R, E, A>
}

Added in v2.4.4 v2.4.4 中添加

filterOrElseW   过滤器否则W

Less strict version of filterOrElse.
filterOrElse 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const filterOrElseW: {
  <A, B extends A, E2>(refinement: Refinement<A, B>, onFalse: (a: A) => E2): <S, R, E1>(
    ma: StateReaderTaskEither<S, R, E1, A>
  ) => StateReaderTaskEither<S, R, E2 | E1, B>
  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <S, R, E1, B extends A>(
    mb: StateReaderTaskEither<S, R, E1, B>
  ) => StateReaderTaskEither<S, R, E2 | E1, B>
  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <S, R, E1>(
    ma: StateReaderTaskEither<S, R, E1, A>
  ) => StateReaderTaskEither<S, R, E2 | E1, A>
}

Added in v2.9.0 v2.9.0中添加

instances   实例

Alt   替代

Signature 签名

export declare const Alt: Alt4<'StateReaderTaskEither'>

Added in v2.7.0 v2.7.0 中添加

Applicative   适用性

Signature 签名

export declare const Applicative: Applicative4<'StateReaderTaskEither'>

Added in v2.7.0 v2.7.0 中添加

Apply   申请

Signature 签名

export declare const Apply: Apply4<'StateReaderTaskEither'>

Added in v2.10.0 v2.10.0 中添加

Bifunctor   双函子

Signature 签名

export declare const Bifunctor: Bifunctor4<'StateReaderTaskEither'>

Added in v2.7.0 v2.7.0 中添加

Chain  

Signature 签名

export declare const Chain: chainable.Chain4<'StateReaderTaskEither'>

Added in v2.10.0 v2.10.0 中添加

FromEither   来自任一

Signature 签名

export declare const FromEither: FromEither4<'StateReaderTaskEither'>

Added in v2.10.0 v2.10.0 中添加

FromIO   来自IO

Signature 签名

export declare const FromIO: FromIO4<'StateReaderTaskEither'>

Added in v2.10.0 v2.10.0 中添加

FromReader   来自读者

Signature 签名

export declare const FromReader: FromReader4<'StateReaderTaskEither'>

Added in v2.11.0 v2.11.0 中添加

FromState   来自州

Signature 签名

export declare const FromState: FromState4<'StateReaderTaskEither'>

Added in v2.11.0 v2.11.0 中添加

FromTask   来自任务

Signature 签名

export declare const FromTask: FromTask4<'StateReaderTaskEither'>

Added in v2.10.0 v2.10.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor4<'StateReaderTaskEither'>

Added in v2.7.0 v2.7.0 中添加

Monad   单子

Signature 签名

export declare const Monad: Monad4<'StateReaderTaskEither'>

Added in v2.10.0 v2.10.0 中添加

MonadIO   莫纳德奥

Signature 签名

export declare const MonadIO: MonadIO4<'StateReaderTaskEither'>

Added in v2.10.0 v2.10.0 中添加

MonadTask  单子任务

Signature 签名

export declare const MonadTask: MonadTask4<'StateReaderTaskEither'>

Added in v2.10.0 v2.10.0 中添加

MonadThrow   单子投掷

Signature 签名

export declare const MonadThrow: MonadThrow4<'StateReaderTaskEither'>

Added in v2.10.0 v2.10.0 中添加

Pointed  

Signature 签名

export declare const Pointed: Pointed4<'StateReaderTaskEither'>

Added in v2.10.0 v2.10.0 中添加

legacy   遗产

chain  

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chain: <S, R, E, A, B>(
  f: (a: A) => StateReaderTaskEither<S, R, E, B>
) => (ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>

Added in v2.0.0 v2.0.0 中添加

chainEitherK  链EiK

Alias of flatMapEither.  flatMapEither 的别名。

Signature 签名

export declare const chainEitherK: <E, A, B>(
  f: (a: A) => E.Either<E, B>
) => <S, R>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>

Added in v2.4.0 v2.4.0中添加

chainEitherKW  链条任一KW

Alias of flatMapEither.  flatMapEither 的别名。

Less strict version of chainEitherK.
chainEitherK 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const chainEitherKW: <E2, A, B>(
  f: (a: A) => E.Either<E2, B>
) => <S, R, E1>(ma: StateReaderTaskEither<S, R, E1, A>) => StateReaderTaskEither<S, R, E2 | E1, B>

Added in v2.6.1 v2.6.1 中添加

chainFirst   链优先

Alias of tap.  tap 的别名。

Signature 签名

export declare const chainFirst: <S, R, E, A, B>(
  f: (a: A) => StateReaderTaskEither<S, R, E, B>
) => (ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>

Added in v2.0.0 v2.0.0 中添加

chainFirstEitherK  链FirstEiK

Alias of tapEither.  tapEither 的别名。

Signature 签名

export declare const chainFirstEitherK: <A, E, B>(
  f: (a: A) => E.Either<E, B>
) => <S, R>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>

Added in v2.12.0 v2.12.0 中添加

chainFirstEitherKW   链FirstEiKW

Alias of tapEither.  tapEither 的别名。

Less strict version of chainFirstEitherK.
chainFirstEitherK 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const chainFirstEitherKW: <A, E2, B>(
  f: (a: A) => E.Either<E2, B>
) => <S, R, E1>(ma: StateReaderTaskEither<S, R, E1, A>) => StateReaderTaskEither<S, R, E2 | E1, A>

Added in v2.12.0 v2.12.0 中添加

chainFirstIOK  链第一IOK

Alias of tapIO.  tapIO 的别名。

Signature 签名

export declare const chainFirstIOK: <A, B>(
  f: (a: A) => IO<B>
) => <S, R, E>(first: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>

Added in v2.10.0 v2.10.0 中添加

chainFirstReaderK  链第一读者K

Alias of tapReader.  tapReader 的别名。

Signature 签名

export declare const chainFirstReaderK: <A, R, B>(
  f: (a: A) => R.Reader<R, B>
) => <S, E>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>

Added in v2.11.0 v2.11.0 中添加

chainFirstReaderKW  chainFirstReaderKW

Alias of tapReader.  tapReader 的别名。

Less strict version of chainFirstReaderK.
chainFirstReaderK 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const chainFirstReaderKW: <A, R1, B>(
  f: (a: A) => R.Reader<R1, B>
) => <S, R2, E>(ma: StateReaderTaskEither<S, R2, E, A>) => StateReaderTaskEither<S, R1 & R2, E, A>

Added in v2.11.0 v2.11.0 中添加

chainFirstTaskK  链第一任务K

Alias of tapTask.  tapTask 的别名。

Signature 签名

export declare const chainFirstTaskK: <A, B>(
  f: (a: A) => Task<B>
) => <S, R, E>(first: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>

Added in v2.10.0 v2.10.0 中添加

chainFirstW  链优先W

Alias of tap.  tap 的别名。

Signature 签名

export declare const chainFirstW: <S, R2, E2, A, B>(
  f: (a: A) => StateReaderTaskEither<S, R2, E2, B>
) => <R1, E1>(ma: StateReaderTaskEither<S, R1, E1, A>) => StateReaderTaskEither<S, R1 & R2, E2 | E1, A>

Added in v2.8.0 v2.8.0 中添加

chainIOEitherK  链IOEitherK

Alias of flatMapIOEither.  flatMapIOEither 的别名。

Signature 签名

export declare const chainIOEitherK: <E, A, B>(
  f: (a: A) => IOEither<E, B>
) => <S, R>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>

Added in v2.4.0 v2.4.0中添加

chainIOEitherKW   链IOEitherKW

Alias of flatMapIOEither.  flatMapIOEither 的别名。

Less strict version of chainIOEitherK.
chainIOEitherK 的不太严格版本。

Signature 签名

export declare const chainIOEitherKW: <E2, A, B>(
  f: (a: A) => IOEither<E2, B>
) => <S, R, E1>(ma: StateReaderTaskEither<S, R, E1, A>) => StateReaderTaskEither<S, R, E2 | E1, B>

Added in v2.6.1 v2.6.1 中添加

chainIOK  链IOK

Alias of flatMapIO.  flatMapIO 的别名。

Signature 签名

export declare const chainIOK: <A, B>(
  f: (a: A) => IO<B>
) => <S, R, E>(first: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>

Added in v2.10.0 v2.10.0 中添加

chainOptionK   链选项K

Use flatMapOption. 使用 flatMapOption

Signature 签名

export declare const chainOptionK: <E>(
  onNone: LazyArg<E>
) => <A, B>(
  f: (a: A) => Option<B>
) => <S, R>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>

Added in v2.10.0 v2.10.0 中添加

chainOptionKW   链条选项KW

Use flatMapOption. 使用 flatMapOption

Less strict version of chainOptionK.
chainOptionK 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const chainOptionKW: <E2>(
  onNone: LazyArg<E2>
) => <A, B>(
  f: (a: A) => Option<B>
) => <S, R, E1>(ma: StateReaderTaskEither<S, R, E1, A>) => StateReaderTaskEither<S, R, E2 | E1, B>

Added in v2.13.2 v2.13.2 中添加

chainReaderK  链读器K

Alias of flatMapReader.  flatMapReader 的别名。

Signature 签名

export declare const chainReaderK: <A, R, B>(
  f: (a: A) => R.Reader<R, B>
) => <S, E>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>

Added in v2.11.0 v2.11.0 中添加

chainReaderKW  链式阅读器KW

Alias of flatMapReader.  flatMapReader 的别名。

Less strict version of chainReaderK.
chainReaderK 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const chainReaderKW: <A, R1, B>(
  f: (a: A) => R.Reader<R1, B>
) => <S, R2, E>(ma: StateReaderTaskEither<S, R2, E, A>) => StateReaderTaskEither<S, R1 & R2, E, B>

Added in v2.11.0 v2.11.0 中添加

chainReaderTaskEitherK  chainReaderTaskEitherK

Alias of flatMapReaderTaskEither.  flatMapReaderTaskEither 的别名。

Signature 签名

export declare const chainReaderTaskEitherK: <R, E, A, B>(
  f: (a: A) => RTE.ReaderTaskEither<R, E, B>
) => <S>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>

Added in v2.4.0 v2.4.0中添加

chainReaderTaskEitherKW
chainReaderTaskEitherKW

Alias of flatMapReaderTaskEither.  flatMapReaderTaskEither 的别名。

Less strict version of chainReaderTaskEitherK.
chainReaderTaskEitherK 的不太严格版本。

Signature 签名

export declare const chainReaderTaskEitherKW: <R, E2, A, B>(
  f: (a: A) => RTE.ReaderTaskEither<R, E2, B>
) => <S, E1>(ma: StateReaderTaskEither<S, R, E1, A>) => StateReaderTaskEither<S, R, E2 | E1, B>

Added in v2.6.1 v2.6.1 中添加

chainStateK   链状态K

Alias of flatMapState.  flatMapState 的别名。

Signature 签名

export declare const chainStateK: <A, S, B>(
  f: (a: A) => State<S, B>
) => <R, E>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>

Added in v2.11.0 v2.11.0 中添加

chainTaskEitherK   chainTaskEitherK

Alias of flatMapTaskEither.  flatMapTaskEither 的别名。

Signature 签名

export declare const chainTaskEitherK: <E, A, B>(
  f: (a: A) => TaskEither<E, B>
) => <S, R>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>

Added in v2.4.0 v2.4.0中添加

chainTaskEitherKW   chainTaskEitherKW

Alias of flatMapTaskEither.  flatMapTaskEither 的别名。

Less strict version of chainTaskEitherK.
chainTaskEitherK 的不太严格版本。

Signature 签名

export declare const chainTaskEitherKW: <E2, A, B>(
  f: (a: A) => TaskEither<E2, B>
) => <S, R, E1>(ma: StateReaderTaskEither<S, R, E1, A>) => StateReaderTaskEither<S, R, E2 | E1, B>

Added in v2.6.1 v2.6.1 中添加

chainTaskK  链任务K

Alias of flatMapTask.  flatMapTask 的别名。

Signature 签名

export declare const chainTaskK: <A, B>(
  f: (a: A) => Task<B>
) => <S, R, E>(first: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>

Added in v2.10.0 v2.10.0 中添加

chainW   链W

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chainW: <S, R2, E2, A, B>(
  f: (a: A) => StateReaderTaskEither<S, R2, E2, B>
) => <R1, E1>(ma: StateReaderTaskEither<S, R1, E1, A>) => StateReaderTaskEither<S, R1 & R2, E2 | E1, B>

Added in v2.6.0 v2.6.0 中添加

lifting   起重

fromEitherK   来自EitherK

Signature 签名

export declare const fromEitherK: <E, A extends readonly unknown[], B>(
  f: (...a: A) => E.Either<E, B>
) => <S, R = unknown>(...a: A) => StateReaderTaskEither<S, R, E, B>

Added in v2.4.0 v2.4.0中添加

fromIOEitherK   来自IOEitherK

Signature 签名

export declare const fromIOEitherK: <E, A extends readonly unknown[], B>(
  f: (...a: A) => IOEither<E, B>
) => <S, R = unknown>(...a: A) => StateReaderTaskEither<S, R, E, B>

Added in v2.4.0 v2.4.0中添加

fromIOK   来自IOK

Signature 签名

export declare const fromIOK: <A extends readonly unknown[], B>(
  f: (...a: A) => IO<B>
) => <S, R = unknown, E = never>(...a: A) => StateReaderTaskEither<S, R, E, B>

Added in v2.10.0 v2.10.0 中添加

fromOptionK   来自选项K

Signature 签名

export declare const fromOptionK: <E>(
  onNone: LazyArg<E>
) => <A extends readonly unknown[], B>(
  f: (...a: A) => Option<B>
) => <S, R = unknown>(...a: A) => StateReaderTaskEither<S, R, E, B>

Added in v2.10.0 v2.10.0 中添加

fromPredicate   来自谓词

Signature 签名

export declare const fromPredicate: {
  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <S, R = unknown>(
    a: A
  ) => StateReaderTaskEither<S, R, E, B>
  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R = unknown, B extends A = A>(
    b: B
  ) => StateReaderTaskEither<S, R, E, B>
  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R = unknown>(a: A) => StateReaderTaskEither<S, R, E, A>
}

Added in v2.4.4 v2.4.4 中添加

fromReaderK   来自ReaderK

Signature 签名

export declare const fromReaderK: <A extends readonly unknown[], R, B>(
  f: (...a: A) => R.Reader<R, B>
) => <S, E = never>(...a: A) => StateReaderTaskEither<S, R, E, B>

Added in v2.11.0 v2.11.0 中添加

fromReaderTaskEitherK   来自ReaderTaskEitherK

Signature 签名

export declare const fromReaderTaskEitherK: <R, E, A extends readonly unknown[], B>(
  f: (...a: A) => RTE.ReaderTaskEither<R, E, B>
) => <S>(...a: A) => StateReaderTaskEither<S, R, E, B>

Added in v2.4.0 v2.4.0中添加

fromStateK   来自K州

Signature 签名

export declare const fromStateK: <A extends readonly unknown[], S, B>(
  f: (...a: A) => State<S, B>
) => <R = unknown, E = never>(...a: A) => StateReaderTaskEither<S, R, E, B>

Added in v2.11.0 v2.11.0 中添加

fromTaskEitherK  来自TaskEitherK

Signature 签名

export declare const fromTaskEitherK: <E, A extends readonly unknown[], B>(
  f: (...a: A) => TaskEither<E, B>
) => <S, R = unknown>(...a: A) => StateReaderTaskEither<S, R, E, B>

Added in v2.4.0 v2.4.0中添加

fromTaskK   来自任务K

Signature 签名

export declare const fromTaskK: <A extends readonly unknown[], B>(
  f: (...a: A) => Task<B>
) => <S, R = unknown, E = never>(...a: A) => StateReaderTaskEither<S, R, E, B>

Added in v2.10.0 v2.10.0 中添加

mapping   映射

as   作为

Maps the Right value of this StateReaderTaskEither to the specified constant value.
将此 StateReaderTaskEitherRight 值映射到指定的常量值。

Signature 签名

export declare const as: {
  <A>(a: A): <S, R, E, _>(self: StateReaderTaskEither<S, R, E, _>) => StateReaderTaskEither<S, R, E, A>
  <S, R, E, _, A>(self: StateReaderTaskEither<S, R, E, _>, a: A): StateReaderTaskEither<S, R, E, A>
}

Added in v2.16.0 v2.16.0 中添加

asUnit   作为单位

Maps the Right value of this StateReaderTaskEither to the void constant value.
将此 StateReaderTaskEitherRight 值映射到void 常量值。

Signature 签名

export declare const asUnit: <S, R, E, _>(
  self: StateReaderTaskEither<S, R, E, _>
) => StateReaderTaskEither<S, R, E, void>

Added in v2.16.0 v2.16.0 中添加

bimap   双图

Map a pair of functions over the two last type arguments of the bifunctor.
将一对函数映射到双函子的最后两个类型参数上。

Signature 签名

export declare const bimap: <E, G, A, B>(
  f: (e: E) => G,
  g: (a: A) => B
) => <S, R>(fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, G, B>

Added in v2.6.2 v2.6.2 中添加

flap   皮瓣

Signature 签名

export declare const flap: <A>(
  a: A
) => <S, R, E, B>(fab: StateReaderTaskEither<S, R, E, (a: A) => B>) => StateReaderTaskEither<S, R, E, B>

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(
  f: (a: A) => B
) => <S, R, E>(fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>

Added in v2.0.0 v2.0.0 中添加

model   模型

StateReaderTaskEither (interface)
StateReaderTaskEither(接口)

Signature 签名

export interface StateReaderTaskEither<S, R, E, A> {
  (s: S): ReaderTaskEither<R, E, [A, S]>
}

Added in v2.0.0 v2.0.0 中添加

sequencing   测序

flatMap   平面地图

Signature 签名

export declare const flatMap: {
  <A, S, R2, E2, B>(f: (a: A) => StateReaderTaskEither<S, R2, E2, B>): <R1, E1>(
    ma: StateReaderTaskEither<S, R1, E1, A>
  ) => StateReaderTaskEither<S, R1 & R2, E2 | E1, B>
  <S, R1, E1, A, R2, E2, B>(
    ma: StateReaderTaskEither<S, R1, E1, A>,
    f: (a: A) => StateReaderTaskEither<S, R2, E2, B>
  ): StateReaderTaskEither<S, R1 & R2, E1 | E2, B>
}

Added in v2.14.0 v2.14.0 中添加

flatMapEither   平面地图要么

Signature 签名

export declare const flatMapEither: {
  <A, E2, B>(f: (a: A) => E.Either<E2, B>): <S, R, E1>(
    self: StateReaderTaskEither<S, R, E1, A>
  ) => StateReaderTaskEither<S, R, E2 | E1, B>
  <S, R, E1, A, E2, B>(self: StateReaderTaskEither<S, R, E1, A>, f: (a: A) => E.Either<E2, B>): StateReaderTaskEither<
    S,
    R,
    E1 | E2,
    B
  >
}

Added in v2.16.0 v2.16.0 中添加

flatMapIO   平面MapIO

Signature 签名

export declare const flatMapIO: {
  <A, B>(f: (a: A) => IO<B>): <S, R, E>(self: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>
  <S, R, E, A, B>(self: StateReaderTaskEither<S, R, E, A>, f: (a: A) => IO<B>): StateReaderTaskEither<S, R, E, B>
}

Added in v2.16.0 v2.16.0 中添加

flatMapIOEither   平面MapIO要么

Signature 签名

export declare const flatMapIOEither: {
  <A, E2, B>(f: (a: A) => IOEither<E2, B>): <S, R, E1>(
    self: StateReaderTaskEither<S, R, E1, A>
  ) => StateReaderTaskEither<S, R, E2 | E1, B>
  <S, R, E1, A, E2, B>(self: StateReaderTaskEither<S, R, E1, A>, f: (a: A) => IOEither<E2, B>): StateReaderTaskEither<
    S,
    R,
    E1 | E2,
    B
  >
}

Added in v2.16.0 v2.16.0 中添加

flatMapOption   平面地图选项

Signature 签名

export declare const flatMapOption: {
  <A, E2, B>(f: (a: A) => Option<B>, onNone: (a: A) => E2): <S, R, E1>(
    self: StateReaderTaskEither<S, R, E1, A>
  ) => StateReaderTaskEither<S, R, E2 | E1, B>
  <S, R, E1, A, E2, B>(
    self: StateReaderTaskEither<S, R, E1, A>,
    f: (a: A) => Option<B>,
    onNone: (a: A) => E2
  ): StateReaderTaskEither<S, R, E1 | E2, B>
}

Added in v2.16.0 v2.16.0 中添加

flatMapReader   平面地图阅读器

Signature 签名

export declare const flatMapReader: {
  <A, R2, B>(f: (a: A) => R.Reader<R2, B>): <S, R1, E>(
    self: StateReaderTaskEither<S, R1, E, A>
  ) => StateReaderTaskEither<S, R1 & R2, E, B>
  <S, R1, E, A, R2, B>(self: StateReaderTaskEither<S, R1, E, A>, f: (a: A) => R.Reader<R2, B>): StateReaderTaskEither<
    S,
    R1 & R2,
    E,
    B
  >
}

Added in v2.16.0 v2.16.0 中添加

flatMapReaderTaskEither
flatMapReaderTaskEither

Signature 签名

export declare const flatMapReaderTaskEither: {
  <A, R2, E2, B>(f: (a: A) => RTE.ReaderTaskEither<R2, E2, B>): <S, R1, E1>(
    self: StateReaderTaskEither<S, R1, E1, A>
  ) => StateReaderTaskEither<S, R1 & R2, E2 | E1, B>
  <S, R1, E1, A, R2, E2, B>(
    self: StateReaderTaskEither<S, R1, E1, A>,
    f: (a: A) => RTE.ReaderTaskEither<R2, E2, B>
  ): StateReaderTaskEither<S, R1 & R2, E1 | E2, B>
}

Added in v2.16.0 v2.16.0 中添加

flatMapState  平面地图状态

Signature 签名

export declare const flatMapState: {
  <S, A, B>(f: (a: A) => State<S, B>): <R, E>(
    self: StateReaderTaskEither<S, R, E, A>
  ) => StateReaderTaskEither<S, R, E, B>
  <S, R, E, A, B>(self: StateReaderTaskEither<S, R, E, A>, f: (a: A) => State<S, B>): StateReaderTaskEither<S, R, E, B>
}

Added in v2.16.0 v2.16.0 中添加

flatMapTask  平面地图任务

Signature 签名

export declare const flatMapTask: {
  <A, B>(f: (a: A) => Task<B>): <S, R, E>(self: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>
  <S, R, E, A, B>(self: StateReaderTaskEither<S, R, E, A>, f: (a: A) => Task<B>): StateReaderTaskEither<S, R, E, B>
}

Added in v2.16.0 v2.16.0 中添加

flatMapTaskEither  flatMapTaskEither

Signature 签名

export declare const flatMapTaskEither: {
  <A, E2, B>(f: (a: A) => TaskEither<E2, B>): <S, R, E1>(
    self: StateReaderTaskEither<S, R, E1, A>
  ) => StateReaderTaskEither<S, R, E2 | E1, B>
  <S, R, E1, A, E2, B>(self: StateReaderTaskEither<S, R, E1, A>, f: (a: A) => TaskEither<E2, B>): StateReaderTaskEither<
    S,
    R,
    E1 | E2,
    B
  >
}

Added in v2.16.0 v2.16.0 中添加

flatten   压扁

Signature 签名

export declare const flatten: <S, R, E, A>(
  mma: StateReaderTaskEither<S, R, E, StateReaderTaskEither<S, R, E, A>>
) => StateReaderTaskEither<S, R, E, A>

Added in v2.0.0 v2.0.0 中添加

flattenW   展平W

Less strict version of flatten.
flatten 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const flattenW: <S, R1, E1, R2, E2, A>(
  mma: StateReaderTaskEither<S, R1, E1, StateReaderTaskEither<S, R2, E2, A>>
) => StateReaderTaskEither<S, R1 & R2, E1 | E2, A>

Added in v2.11.0 v2.11.0 中添加

traversing   穿越

sequenceArray   序列数组

Equivalent to ReadonlyArray#sequence(Applicative). 相当于 ReadonlyArray#sequence(Applicative)

Signature 签名

export declare const sequenceArray: <S, R, E, A>(
  arr: readonly StateReaderTaskEither<S, R, E, A>[]
) => StateReaderTaskEither<S, R, E, readonly A[]>

Added in v2.9.0 v2.9.0中添加

traverseArray   遍历数组

Equivalent to ReadonlyArray#traverse(Applicative). 相当于 ReadonlyArray#traverse(Applicative)

Signature 签名

export declare const traverseArray: <S, R, E, A, B>(
  f: (a: A) => StateReaderTaskEither<S, R, E, B>
) => (as: readonly A[]) => StateReaderTaskEither<S, R, E, readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseArrayWithIndex   带索引遍历数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseArrayWithIndex: <S, R, E, A, B>(
  f: (index: number, a: A) => StateReaderTaskEither<S, R, E, B>
) => (as: readonly A[]) => StateReaderTaskEither<S, R, E, readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseReadonlyArrayWithIndex
遍历带索引的只读数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseReadonlyArrayWithIndex: <A, S, R, E, B>(
  f: (index: number, a: A) => StateReaderTaskEither<S, R, E, B>
) => (as: readonly A[]) => StateReaderTaskEither<S, R, E, readonly B[]>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyNonEmptyArrayWithIndex
遍历ReadonlyNonEmptyArrayWithIndex

Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(Applicative). 相当于 ReadonlyNonEmptyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseReadonlyNonEmptyArrayWithIndex: <A, S, R, E, B>(
  f: (index: number, a: A) => StateReaderTaskEither<S, R, E, B>
) => (as: ReadonlyNonEmptyArray<A>) => StateReaderTaskEither<S, R, E, ReadonlyNonEmptyArray<B>>

Added in v2.11.0 v2.11.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'StateReaderTaskEither'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

ap   美联社

Signature 签名

export declare const ap: <S, R, E, A>(
  fa: StateReaderTaskEither<S, R, E, A>
) => <B>(fab: StateReaderTaskEither<S, R, E, (a: A) => B>) => StateReaderTaskEither<S, R, E, B>

Added in v2.0.0 v2.0.0 中添加

apFirst   应用程序第一

Combine two effectful actions, keeping only the result of the first.
结合两个有效的操作,仅保留第一个操作的结果。

Signature 签名

export declare const apFirst: <S, R, E, B>(
  second: StateReaderTaskEither<S, R, E, B>
) => <A>(first: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>

Added in v2.0.0 v2.0.0 中添加

apFirstW   apFirstW

Less strict version of apFirst.
apFirst 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const apFirstW: <S, R2, E2, A, B>(
  second: StateReaderTaskEither<S, R2, E2, B>
) => <R1, E1>(first: StateReaderTaskEither<S, R1, E1, A>) => StateReaderTaskEither<S, R1 & R2, E2 | E1, A>

Added in v2.12.0 v2.12.0 中添加

apS   apS

Signature 签名

export declare const apS: <N, A, S, R, E, B>(
  name: Exclude<N, keyof A>,
  fb: StateReaderTaskEither<S, R, E, B>
) => (
  fa: StateReaderTaskEither<S, R, E, A>
) => StateReaderTaskEither<S, R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

apSecond   ap秒

Combine two effectful actions, keeping only the result of the second.
结合两个有效的操作,只保留第二个的结果。

Signature 签名

export declare const apSecond: <S, R, E, B>(
  second: StateReaderTaskEither<S, R, E, B>
) => <A>(first: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>

Added in v2.0.0 v2.0.0 中添加

apSecondW   apSecondW

Less strict version of apSecond.
apSecond 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const apSecondW: <S, R2, E2, A, B>(
  second: StateReaderTaskEither<S, R2, E2, B>
) => <R1, E1>(first: StateReaderTaskEither<S, R1, E1, A>) => StateReaderTaskEither<S, R1 & R2, E2 | E1, B>

Added in v2.12.0 v2.12.0 中添加

apW   平均功率

Less strict version of ap.
ap 的不太严格版本。

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const apW: <S, R2, E2, A>(
  fa: StateReaderTaskEither<S, R2, E2, A>
) => <R1, E1, B>(fab: StateReaderTaskEither<S, R1, E1, (a: A) => B>) => StateReaderTaskEither<S, R1 & R2, E2 | E1, B>

Added in v2.8.0 v2.8.0 中添加

bind   绑定

Signature 签名

export declare const bind: <N, A, S, R, E, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => StateReaderTaskEither<S, R, E, B>
) => (
  ma: StateReaderTaskEither<S, R, E, A>
) => StateReaderTaskEither<S, R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bindTo   绑定到

Signature 签名

export declare const bindTo: <N>(
  name: N
) => <S, R, E, A>(fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, { readonly [K in N]: A }>

Added in v2.8.0 v2.8.0 中添加

bindW   绑定W

The W suffix (short for Widening) means that the environment types and the error types will be merged.
W 后缀(Widening 的缩写)意味着环境类型和错误类型将被合并。

Signature 签名

export declare const bindW: <N extends string, A, S, R2, E2, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => StateReaderTaskEither<S, R2, E2, B>
) => <R1, E1>(
  fa: StateReaderTaskEither<S, R1, E1, A>
) => StateReaderTaskEither<S, R1 & R2, E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

evaluate   评价

Run a computation in the StateReaderTaskEither monad, discarding the final state
StateReaderTaskEither monad 中运行计算,丢弃最终状态

Signature 签名

export declare const evaluate: <S>(
  s: S
) => <R, E, A>(ma: StateReaderTaskEither<S, R, E, A>) => RTE.ReaderTaskEither<R, E, A>

Added in v2.8.0 v2.8.0 中添加

execute   执行

Run a computation in the StateReaderTaskEither monad discarding the result
StateReaderTaskEither monad 中运行计算并丢弃结果

Signature 签名

export declare const execute: <S>(
  s: S
) => <R, E, A>(ma: StateReaderTaskEither<S, R, E, A>) => RTE.ReaderTaskEither<R, E, S>

Added in v2.8.0 v2.8.0 中添加

let  

Signature 签名

export declare const let: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => <S, R, E>(
  fa: StateReaderTaskEither<S, R, E, A>
) => StateReaderTaskEither<S, R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.13.0 v2.13.0 中添加

local   当地的

Changes the value of the local context during the execution of the action ma (similar to Contravariant’s contramap).
在执行操作 ma 期间更改本地上下文的值(类似于 Contravariantcontramap )。

Signature 签名

export declare const local: <R2, R1>(
  f: (r2: R2) => R1
) => <S, E, A>(ma: StateReaderTaskEither<S, R1, E, A>) => StateReaderTaskEither<S, R2, E, A>

Added in v2.11.0 v2.11.0 中添加

throwError   抛出错误

Signature 签名

export declare const throwError: <S, R, E, A>(e: E) => StateReaderTaskEither<S, R, E, A>

Added in v2.7.0 v2.7.0 中添加

zone of death
死亡地带

evalState 评估状态

Use evaluate instead 使用 evaluate 代替

Signature 签名

export declare const evalState: <S, R, E, A>(
  ma: StateReaderTaskEither<S, R, E, A>,
  s: S
) => RTE.ReaderTaskEither<R, E, A>

Added in v2.0.0 v2.0.0 中添加

execState 执行状态

Use execute instead 使用 execute 代替

Signature 签名

export declare const execState: <S, R, E, A>(
  ma: StateReaderTaskEither<S, R, E, A>,
  s: S
) => RTE.ReaderTaskEither<R, E, S>

Added in v2.0.0 v2.0.0 中添加

run 跑步

Signature 签名

export declare function run<S, R, E, A>(ma: StateReaderTaskEither<S, R, E, A>, s: S, r: R): Promise<Either<E, [A, S]>>

Added in v2.0.0 v2.0.0 中添加

stateReaderTaskEitherSeq
stateReaderTaskEitherSeq

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass SRTE.Functor instead of SRTE.stateReaderTaskEitherSeq (where SRTE is from import SRTE from 'fp-ts/StateReaderTaskEither')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 SRTE.Functor 而不是 SRTE.stateReaderTaskEitherSeq (其中 SRTE 来自 import SRTE from 'fp-ts/StateReaderTaskEither'

Signature 签名

export declare const stateReaderTaskEitherSeq: Monad4<'StateReaderTaskEither'> &
  Bifunctor4<'StateReaderTaskEither'> &
  Alt4<'StateReaderTaskEither'> &
  MonadTask4<'StateReaderTaskEither'> &
  MonadThrow4<'StateReaderTaskEither'>

Added in v2.0.0 v2.0.0 中添加

stateReaderTaskEither 状态ReaderTaskEither

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass SRTE.Functor instead of SRTE.stateReaderTaskEither (where SRTE is from import SRTE from 'fp-ts/StateReaderTaskEither')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 SRTE.Functor 而不是 SRTE.stateReaderTaskEither (其中 SRTE 来自 import SRTE from 'fp-ts/StateReaderTaskEither'

Signature 签名

export declare const stateReaderTaskEither: Monad4<'StateReaderTaskEither'> &
  Bifunctor4<'StateReaderTaskEither'> &
  Alt4<'StateReaderTaskEither'> &
  MonadTask4<'StateReaderTaskEither'> &
  MonadThrow4<'StateReaderTaskEither'>

Added in v2.0.0 v2.0.0 中添加

StateT overview  StateT概述

The state monad transformer. It can be used to add state to other monads.
状态单子变压器。它可用于向其他 monad 添加状态。

The of function leaves the state unchanged, while chain uses the final state of the first computation as the initial state of the second.
of 函数保持状态不变,而 chain 使用第一次计算的最终状态作为第二次计算的初始状态。

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

StateT (interface)   状态T(接口)

Signature 签名

export interface StateT<M, S, A> {
  (s: S): HKT<M, [A, S]>
}

Added in v2.0.0 v2.0.0 中添加

StateT1 (interface)   状态T1(接口)

Signature 签名

export interface StateT1<M extends URIS, S, A> {
  (s: S): Kind<M, [A, S]>
}

Added in v2.0.0 v2.0.0 中添加

StateT2 (interface)   状态T2(接口)

Signature 签名

export interface StateT2<M extends URIS2, S, E, A> {
  (s: S): Kind2<M, E, [A, S]>
}

Added in v2.0.0 v2.0.0 中添加

StateT3 (interface)   状态T3(接口)

Signature 签名

export interface StateT3<M extends URIS3, S, R, E, A> {
  (s: S): Kind3<M, R, E, [A, S]>
}

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

ap   美联社

Signature 签名

export declare function ap<M extends URIS3>(
  M: Chain3<M>
): <S, R, E, A>(fa: StateT3<M, S, R, E, A>) => <B>(fab: StateT3<M, S, R, E, (a: A) => B>) => StateT3<M, S, R, E, B>
export declare function ap<M extends URIS3, E>(
  M: Chain3C<M, E>
): <S, R, A>(fa: StateT3<M, S, R, E, A>) => <B>(fab: StateT3<M, S, R, E, (a: A) => B>) => StateT3<M, S, R, E, B>
export declare function ap<M extends URIS2>(
  M: Chain2<M>
): <S, E, A>(fa: StateT2<M, S, E, A>) => <B>(fab: StateT2<M, S, E, (a: A) => B>) => StateT2<M, S, E, B>
export declare function ap<M extends URIS2, E>(
  M: Chain2C<M, E>
): <S, A>(fa: StateT2<M, S, E, A>) => <B>(fab: StateT2<M, S, E, (a: A) => B>) => StateT2<M, S, E, B>
export declare function ap<M extends URIS>(
  M: Chain1<M>
): <S, A>(fa: StateT1<M, S, A>) => <B>(fab: StateT1<M, S, (a: A) => B>) => StateT1<M, S, B>
export declare function ap<M>(
  M: Chain<M>
): <S, A>(fa: StateT<M, S, A>) => <B>(fab: StateT<M, S, (a: A) => B>) => StateT<M, S, B>

Added in v2.10.0 v2.10.0 中添加

chain  

Signature 签名

export declare function chain<M extends URIS3>(
  M: Chain3<M>
): <A, S, R, E, B>(f: (a: A) => StateT3<M, S, R, E, B>) => (ma: StateT3<M, S, R, E, A>) => StateT3<M, S, R, E, B>
export declare function chain<M extends URIS3, E>(
  M: Chain3C<M, E>
): <A, S, R, B>(f: (a: A) => StateT3<M, S, R, E, B>) => (ma: StateT3<M, S, R, E, A>) => StateT3<M, S, R, E, B>
export declare function chain<M extends URIS2>(
  M: Chain2<M>
): <A, S, E, B>(f: (a: A) => StateT2<M, S, E, B>) => (ma: StateT2<M, S, E, A>) => StateT2<M, S, E, B>
export declare function chain<M extends URIS2, E>(
  M: Chain2C<M, E>
): <A, S, B>(f: (a: A) => StateT2<M, S, E, B>) => (ma: StateT2<M, S, E, A>) => StateT2<M, S, E, B>
export declare function chain<M extends URIS>(
  M: Chain1<M>
): <A, S, B>(f: (a: A) => StateT1<M, S, B>) => (ma: StateT1<M, S, A>) => StateT1<M, S, B>
export declare function chain<M>(
  M: Chain<M>
): <A, S, B>(f: (a: A) => StateT<M, S, B>) => (ma: StateT<M, S, A>) => StateT<M, S, B>

Added in v2.10.0 v2.10.0 中添加

evaluate   评价

Signature 签名

export declare function evaluate<F extends URIS3>(
  F: Functor3<F>
): <S>(s: S) => <R, E, A>(ma: StateT3<F, S, R, E, A>) => Kind3<F, R, E, A>
export declare function evaluate<F extends URIS3, E>(
  F: Functor3C<F, E>
): <S>(s: S) => <R, A>(ma: StateT3<F, S, R, E, A>) => Kind3<F, R, E, A>
export declare function evaluate<F extends URIS2>(
  F: Functor2<F>
): <S>(s: S) => <E, A>(ma: StateT2<F, S, E, A>) => Kind2<F, E, A>
export declare function evaluate<F extends URIS2, E>(
  F: Functor2C<F, E>
): <S>(s: S) => <A>(ma: StateT2<F, S, E, A>) => Kind2<F, E, A>
export declare function evaluate<F extends URIS>(F: Functor1<F>): <S>(s: S) => <A>(ma: StateT1<F, S, A>) => Kind<F, A>
export declare function evaluate<F>(F: Functor<F>): <S>(s: S) => <A>(ma: StateT<F, S, A>) => HKT<F, A>

Added in v2.10.0 v2.10.0 中添加

execute   执行

Signature 签名

export declare function execute<F extends URIS3>(
  F: Functor3<F>
): <S>(s: S) => <R, E, A>(ma: StateT3<F, S, R, E, A>) => Kind3<F, R, E, S>
export declare function execute<F extends URIS3, E>(
  F: Functor3C<F, E>
): <S>(s: S) => <R, A>(ma: StateT3<F, S, R, E, A>) => Kind3<F, R, E, S>
export declare function execute<F extends URIS2>(
  F: Functor2<F>
): <S>(s: S) => <E, A>(ma: StateT2<F, S, E, A>) => Kind2<F, E, S>
export declare function execute<F extends URIS2, E>(
  F: Functor2C<F, E>
): <S>(s: S) => <A>(ma: StateT2<F, S, E, A>) => Kind2<F, E, S>
export declare function execute<F extends URIS>(F: Functor1<F>): <S>(s: S) => <A>(ma: StateT1<F, S, A>) => Kind<F, S>
export declare function execute<F>(F: Functor<F>): <S>(s: S) => <A>(ma: StateT<F, S, A>) => HKT<F, S>

Added in v2.10.0 v2.10.0 中添加

fromF   来自F

Signature 签名

export declare function fromF<F extends URIS3>(
  F: Functor3<F>
): <R, E, A, S>(ma: Kind3<F, R, E, A>) => StateT3<F, S, R, E, A>
export declare function fromF<F extends URIS3, E>(
  F: Functor3C<F, E>
): <R, A, S>(ma: Kind3<F, R, E, A>) => StateT3<F, S, R, E, A>
export declare function fromF<F extends URIS2>(F: Functor2<F>): <E, A, S>(ma: Kind2<F, E, A>) => StateT2<F, S, E, A>
export declare function fromF<F extends URIS2, E>(F: Functor2C<F, E>): <A, S>(ma: Kind2<F, E, A>) => StateT2<F, S, E, A>
export declare function fromF<F extends URIS>(F: Functor1<F>): <A, S>(ma: Kind<F, A>) => StateT1<F, S, A>
export declare function fromF<F>(F: Functor<F>): <A, S>(ma: HKT<F, A>) => StateT<F, S, A>

Added in v2.10.0 v2.10.0 中添加

fromState   来自州

Signature 签名

export declare function fromState<F extends URIS3>(
  F: Pointed3<F>
): <S, A, R, E>(sa: State<S, A>) => StateT3<F, S, R, E, A>
export declare function fromState<F extends URIS3, E>(
  F: Pointed3C<F, E>
): <S, A, R>(sa: State<S, A>) => StateT3<F, S, R, E, A>
export declare function fromState<F extends URIS2>(F: Pointed2<F>): <S, A, E>(sa: State<S, A>) => StateT2<F, S, E, A>
export declare function fromState<F extends URIS2, E>(
  F: Pointed2C<F, E>
): <S, A>(sa: State<S, A>) => StateT2<F, S, E, A>
export declare function fromState<F extends URIS>(F: Pointed1<F>): <S, A>(sa: State<S, A>) => StateT1<F, S, A>
export declare function fromState<F>(F: Pointed<F>): <S, A>(sa: State<S, A>) => StateT<F, S, A>

Added in v2.10.0 v2.10.0 中添加

map   地图

Signature 签名

export declare function map<F extends URIS3>(
  F: Functor3<F>
): <A, B>(f: (a: A) => B) => <S, R, E>(fa: StateT3<F, S, R, E, A>) => StateT3<F, S, R, E, B>
export declare function map<F extends URIS3, E>(
  F: Functor3C<F, E>
): <A, B>(f: (a: A) => B) => <S, R>(fa: StateT3<F, S, R, E, A>) => StateT3<F, S, R, E, B>
export declare function map<F extends URIS2>(
  F: Functor2<F>
): <A, B>(f: (a: A) => B) => <S, E>(fa: StateT2<F, S, E, A>) => StateT2<F, S, E, B>
export declare function map<F extends URIS2, E>(
  F: Functor2C<F, E>
): <A, B>(f: (a: A) => B) => <S>(fa: StateT2<F, S, E, A>) => StateT2<F, S, E, B>
export declare function map<F extends URIS>(
  F: Functor1<F>
): <A, B>(f: (a: A) => B) => <S>(fa: StateT1<F, S, A>) => StateT1<F, S, B>
export declare function map<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => <S>(fa: StateT<F, S, A>) => StateT<F, S, B>

Added in v2.10.0 v2.10.0 中添加

of  

Signature 签名

export declare function of<F extends URIS3>(F: Pointed3<F>): <A, S, R, E>(a: A) => StateT3<F, S, R, E, A>
export declare function of<F extends URIS3, E>(F: Pointed3C<F, E>): <A, S, R>(a: A) => StateT3<F, S, R, E, A>
export declare function of<F extends URIS2>(F: Pointed2<F>): <A, S, E>(a: A) => StateT2<F, S, E, A>
export declare function of<F extends URIS2, E>(F: Pointed2C<F, E>): <A, S>(a: A) => StateT2<F, S, E, A>
export declare function of<F extends URIS>(F: Pointed1<F>): <A, S>(a: A) => StateT1<F, S, A>
export declare function of<F>(F: Pointed<F>): <A, S>(a: A) => StateT<F, S, A>

Added in v2.10.0 v2.10.0 中添加

zone of death
死亡地带

StateM1 状态M1 (interface)   (界面)

Signature 签名

export interface StateM1<M extends URIS> {
  readonly map: <S, A, B>(fa: StateT1<M, S, A>, f: (a: A) => B) => StateT1<M, S, B>
  readonly of: <S, A>(a: A) => StateT1<M, S, A>
  readonly ap: <S, A, B>(fab: StateT1<M, S, (a: A) => B>, fa: StateT1<M, S, A>) => StateT1<M, S, B>
  readonly chain: <S, A, B>(fa: StateT1<M, S, A>, f: (a: A) => StateT1<M, S, B>) => StateT1<M, S, B>
  readonly get: <S>() => StateT1<M, S, S>
  readonly put: <S>(s: S) => StateT1<M, S, void>
  readonly modify: <S>(f: (s: S) => S) => StateT1<M, S, void>
  readonly gets: <S, A>(f: (s: S) => A) => StateT1<M, S, A>
  readonly fromState: <S, A>(fa: State<S, A>) => StateT1<M, S, A>
  readonly fromM: <S, A>(ma: Kind<M, A>) => StateT1<M, S, A>
  readonly evalState: <S, A>(ma: StateT1<M, S, A>, s: S) => Kind<M, A>
  readonly execState: <S, A>(ma: StateT1<M, S, A>, s: S) => Kind<M, S>
}

Added in v2.0.0 v2.0.0 中添加

StateM2C 状态M2C (interface)   (界面)

Signature 签名

export interface StateM2C<M extends URIS2, E> {
  readonly map: <S, A, B>(fa: StateT2<M, S, E, A>, f: (a: A) => B) => StateT2<M, S, E, B>
  readonly of: <S, A>(a: A) => StateT2<M, S, E, A>
  readonly ap: <S, A, B>(fab: StateT2<M, S, E, (a: A) => B>, fa: StateT2<M, S, E, A>) => StateT2<M, S, E, B>
  readonly chain: <S, A, B>(fa: StateT2<M, S, E, A>, f: (a: A) => StateT2<M, S, E, B>) => StateT2<M, S, E, B>
  readonly get: <S>() => StateT2<M, S, E, S>
  readonly put: <S>(s: S) => StateT2<M, S, E, void>
  readonly modify: <S>(f: (s: S) => S) => StateT2<M, S, E, void>
  readonly gets: <S, A>(f: (s: S) => A) => StateT2<M, S, E, A>
  readonly fromState: <S, A>(fa: State<S, A>) => StateT2<M, S, E, A>
  readonly fromM: <S, A>(ma: Kind2<M, E, A>) => StateT2<M, S, E, A>
  readonly evalState: <S, A>(ma: StateT2<M, S, E, A>, s: S) => Kind2<M, E, A>
  readonly execState: <S, A>(ma: StateT2<M, S, E, A>, s: S) => Kind2<M, E, S>
}

Added in v2.5.4 v2.5.4 中添加

StateM2 状态M2 (interface)   (界面)

Signature 签名

export interface StateM2<M extends URIS2> {
  readonly map: <S, E, A, B>(fa: StateT2<M, S, E, A>, f: (a: A) => B) => StateT2<M, S, E, B>
  readonly of: <S, E, A>(a: A) => StateT2<M, S, E, A>
  readonly ap: <S, E, A, B>(fab: StateT2<M, S, E, (a: A) => B>, fa: StateT2<M, S, E, A>) => StateT2<M, S, E, B>
  readonly chain: <S, E, A, B>(fa: StateT2<M, S, E, A>, f: (a: A) => StateT2<M, S, E, B>) => StateT2<M, S, E, B>
  readonly get: <E, S>() => StateT2<M, S, E, S>
  readonly put: <E, S>(s: S) => StateT2<M, S, E, void>
  readonly modify: <E, S>(f: (s: S) => S) => StateT2<M, S, E, void>
  readonly gets: <S, E, A>(f: (s: S) => A) => StateT2<M, S, E, A>
  readonly fromState: <S, E, A>(fa: State<S, A>) => StateT2<M, S, E, A>
  readonly fromM: <S, E, A>(ma: Kind2<M, E, A>) => StateT2<M, S, E, A>
  readonly evalState: <S, E, A>(ma: StateT2<M, S, E, A>, s: S) => Kind2<M, E, A>
  readonly execState: <S, E, A>(ma: StateT2<M, S, E, A>, s: S) => Kind2<M, E, S>
}

Added in v2.0.0 v2.0.0 中添加

StateM3C 状态M3C (interface)   (界面)

Signature 签名

export interface StateM3C<M extends URIS3, E> {
  readonly map: <S, R, A, B>(fa: StateT3<M, S, R, E, A>, f: (a: A) => B) => StateT3<M, S, R, E, B>
  readonly of: <S, R, A>(a: A) => StateT3<M, S, R, E, A>
  readonly ap: <S, R, A, B>(fab: StateT3<M, S, R, E, (a: A) => B>, fa: StateT3<M, S, R, E, A>) => StateT3<M, S, R, E, B>
  readonly chain: <S, R, A, B>(
    fa: StateT3<M, S, R, E, A>,
    f: (a: A) => StateT3<M, S, R, E, B>
  ) => StateT3<M, S, R, E, B>
  readonly get: <R, S>() => StateT3<M, S, R, E, S>
  readonly put: <R, S>(s: S) => StateT3<M, S, R, E, void>
  readonly modify: <R, S>(f: (s: S) => S) => StateT3<M, S, R, E, void>
  readonly gets: <S, R, A>(f: (s: S) => A) => StateT3<M, S, R, E, A>
  readonly fromState: <S, R, A>(fa: State<S, A>) => StateT3<M, S, R, E, A>
  readonly fromM: <S, R, A>(ma: Kind3<M, R, E, A>) => StateT3<M, S, R, E, A>
  readonly evalState: <S, R, A>(ma: StateT3<M, S, R, E, A>, s: S) => Kind3<M, R, E, A>
  readonly execState: <S, R, A>(ma: StateT3<M, S, R, E, A>, s: S) => Kind3<M, R, E, S>
}

Added in v2.5.4 v2.5.4 中添加

StateM3 状态M3 (interface)   (界面)

Signature 签名

export interface StateM3<M extends URIS3> {
  readonly map: <S, R, E, A, B>(fa: StateT3<M, S, R, E, A>, f: (a: A) => B) => StateT3<M, S, R, E, B>
  readonly of: <S, R, E, A>(a: A) => StateT3<M, S, R, E, A>
  readonly ap: <S, R, E, A, B>(
    fab: StateT3<M, S, R, E, (a: A) => B>,
    fa: StateT3<M, S, R, E, A>
  ) => StateT3<M, S, R, E, B>
  readonly chain: <S, R, E, A, B>(
    fa: StateT3<M, S, R, E, A>,
    f: (a: A) => StateT3<M, S, R, E, B>
  ) => StateT3<M, S, R, E, B>
  readonly get: <R, E, S>() => StateT3<M, S, R, E, S>
  readonly put: <R, E, S>(s: S) => StateT3<M, S, R, E, void>
  readonly modify: <R, E, S>(f: (s: S) => S) => StateT3<M, S, R, E, void>
  readonly gets: <S, R, E, A>(f: (s: S) => A) => StateT3<M, S, R, E, A>
  readonly fromState: <S, R, E, A>(fa: State<S, A>) => StateT3<M, S, R, E, A>
  readonly fromM: <S, R, E, A>(ma: Kind3<M, R, E, A>) => StateT3<M, S, R, E, A>
  readonly evalState: <S, R, E, A>(ma: StateT3<M, S, R, E, A>, s: S) => Kind3<M, R, E, A>
  readonly execState: <S, R, E, A>(ma: StateT3<M, S, R, E, A>, s: S) => Kind3<M, R, E, S>
}

Added in v2.0.0 v2.0.0 中添加

StateM 状态M (interface)   (界面)

Signature 签名

export interface StateM<M> {
  readonly map: <S, A, B>(fa: StateT<M, S, A>, f: (a: A) => B) => StateT<M, S, B>
  readonly of: <S, A>(a: A) => StateT<M, S, A>
  readonly ap: <S, A, B>(fab: StateT<M, S, (a: A) => B>, fa: StateT<M, S, A>) => StateT<M, S, B>
  readonly chain: <S, A, B>(fa: StateT<M, S, A>, f: (a: A) => StateT<M, S, B>) => StateT<M, S, B>
  readonly get: <S>() => StateT<M, S, S>
  readonly put: <S>(s: S) => StateT<M, S, void>
  readonly modify: <S>(f: (s: S) => S) => StateT<M, S, void>
  readonly gets: <S, A>(f: (s: S) => A) => StateT<M, S, A>
  readonly fromState: <S, A>(fa: State<S, A>) => StateT<M, S, A>
  readonly fromM: <S, A>(ma: HKT<M, A>) => StateT<M, S, A>
  readonly evalState: <S, A>(ma: StateT<M, S, A>, s: S) => HKT<M, A>
  readonly execState: <S, A>(ma: StateT<M, S, A>, s: S) => HKT<M, S>
}

Added in v2.0.0 v2.0.0 中添加

getStateM 获取状态M

Signature 签名

export declare function getStateM<M extends URIS3>(M: Monad3<M>): StateM3<M>
export declare function getStateM<M extends URIS3, E>(M: Monad3C<M, E>): StateM3C<M, E>
export declare function getStateM<M extends URIS2>(M: Monad2<M>): StateM2<M>
export declare function getStateM<M extends URIS2, E>(M: Monad2C<M, E>): StateM2C<M, E>
export declare function getStateM<M extends URIS>(M: Monad1<M>): StateM1<M>
export declare function getStateM<M>(M: Monad<M>): StateM<M>

Added in v2.0.0 v2.0.0 中添加

Store overview  店铺概览

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


Extract   提炼

extract   提炼

Signature 签名

export declare const extract: <E, A>(wa: Store<E, A>) => A

Added in v2.6.2 v2.6.2 中添加

instances   实例

Comonad   科莫纳德

Signature 签名

export declare const Comonad: Comonad2<'Store'>

Added in v2.7.0 v2.7.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor2<'Store'>

Added in v2.7.0 v2.7.0 中添加

mapping   映射

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <E, B>(fab: Store<E, (a: A) => B>) => Store<E, B>

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => <E>(fa: Store<E, A>) => Store<E, B>

Added in v2.0.0 v2.0.0 中添加

model   模型

Store (interface)   商店(界面)

Signature 签名

export interface Store<S, A> {
  readonly peek: (s: S) => A
  readonly pos: S
}

Added in v2.0.0 v2.0.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'Store'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

duplicate   复制

Signature 签名

export declare const duplicate: <E, A>(wa: Store<E, A>) => Store<E, Store<E, A>>

Added in v2.0.0 v2.0.0 中添加

experiment   实验

Extract a collection of values from positions which depend on the current position
从取决于当前位置的位置中提取值的集合

Signature 签名

export declare function experiment<F extends URIS3>(
  F: Functor3<F>
): <R, E, S>(f: (s: S) => Kind3<F, R, E, S>) => <A>(wa: Store<S, A>) => Kind3<F, R, E, A>
export declare function experiment<F extends URIS3, E>(
  F: Functor3C<F, E>
): <R, S>(f: (s: S) => Kind3<F, R, E, S>) => <A>(wa: Store<S, A>) => Kind3<F, R, E, A>
export declare function experiment<F extends URIS2>(
  F: Functor2<F>
): <E, S>(f: (s: S) => Kind2<F, E, S>) => <A>(wa: Store<S, A>) => Kind2<F, E, A>
export declare function experiment<F extends URIS2, E>(
  F: Functor2C<F, E>
): <S>(f: (s: S) => Kind2<F, E, S>) => <A>(wa: Store<S, A>) => Kind2<F, E, A>
export declare function experiment<F extends URIS>(
  F: Functor1<F>
): <S>(f: (s: S) => Kind<F, S>) => <A>(wa: Store<S, A>) => Kind<F, A>
export declare function experiment<F>(
  F: FunctorHKT<F>
): <S>(f: (s: S) => HKT<F, S>) => <A>(wa: Store<S, A>) => HKT<F, A>

Added in v2.0.0 v2.0.0 中添加

extend   延长

Signature 签名

export declare const extend: <E, A, B>(f: (wa: Store<E, A>) => B) => (wa: Store<E, A>) => Store<E, B>

Added in v2.0.0 v2.0.0 中添加

peeks   偷看

Extract a value from a position which depends on the current position
从取决于当前位置的位置提取值

Signature 签名

export declare function peeks<S>(f: Endomorphism<S>): <A>(wa: Store<S, A>) => A

Added in v2.0.0 v2.0.0 中添加

seek   寻找

Reposition the focus at the specified position
将焦点重新定位到指定位置

Signature 签名

export declare function seek<S>(s: S): <A>(wa: Store<S, A>) => Store<S, A>

Added in v2.0.0 v2.0.0 中添加

seeks   寻求

Reposition the focus at the specified position, which depends on the current position
将焦点重新定位在指定位置,这取决于当前位置

Signature 签名

export declare function seeks<S>(f: Endomorphism<S>): <A>(wa: Store<S, A>) => Store<S, A>

Added in v2.0.0 v2.0.0 中添加

zone of death
死亡地带

store 店铺

This instance is deprecated, use small, specific instances instead. For example if a function needs a Comonad instance, pass S.Comonad instead of S.store (where S is from import S from 'fp-ts/Store')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Comonad 实例,请传递 S.Comonad 而不是 S.store (其中 S 来自 import S from 'fp-ts/Store'

Signature 签名

export declare const store: Comonad2<'Store'>

Added in v2.0.0 v2.0.0 中添加

string overview  字符串概述

Added in v2.10.0 v2.10.0 中添加


Table of contents
目录


instances   实例

Eq   方程

Signature 签名

export declare const Eq: E.Eq<string>

Example 例子

import * as S from 'fp-ts/string'

assert.deepStrictEqual(S.Eq.equals('a', 'a'), true)
assert.deepStrictEqual(S.Eq.equals('a', 'b'), false)

Added in v2.10.0 v2.10.0 中添加

Monoid   幺半群

string monoid under concatenation.
string 串联下的幺半群。

The empty value is ''.
empty 值为 ''

Signature 签名

export declare const Monoid: M.Monoid<string>

Example 例子

import * as S from 'fp-ts/string'

assert.deepStrictEqual(S.Monoid.concat('a', 'b'), 'ab')
assert.deepStrictEqual(S.Monoid.concat('a', S.Monoid.empty), 'a')

Added in v2.10.0 v2.10.0 中添加

Ord   奥德

Signature 签名

export declare const Ord: O.Ord<string>

Example 例子

import * as S from 'fp-ts/string'

assert.deepStrictEqual(S.Ord.compare('a', 'a'), 0)
assert.deepStrictEqual(S.Ord.compare('a', 'b'), -1)
assert.deepStrictEqual(S.Ord.compare('b', 'a'), 1)

Added in v2.10.0 v2.10.0 中添加

Semigroup   半群

string semigroup under concatenation.
string 串联半群。

Signature 签名

export declare const Semigroup: S.Semigroup<string>

Example 例子

import * as S from 'fp-ts/string'

assert.deepStrictEqual(S.Semigroup.concat('a', 'b'), 'ab')

Added in v2.10.0 v2.10.0 中添加

Show   展示

Signature 签名

export declare const Show: Sh.Show<string>

Example 例子

import * as S from 'fp-ts/string'

assert.deepStrictEqual(S.Show.show('a'), '"a"')

Added in v2.10.0 v2.10.0 中添加

refinements   改进

isString   是字符串

Signature 签名

export declare const isString: Refinement<unknown, string>

Example 例子

import * as S from 'fp-ts/string'

assert.deepStrictEqual(S.isString('a'), true)
assert.deepStrictEqual(S.isString(1), false)

Added in v2.11.0 v2.11.0 中添加

utils   实用程序

empty   空的

An empty string. 一个空的 string

Signature 签名

export declare const empty: ''

Added in v2.10.0 v2.10.0 中添加

endsWith   以。。结束

Signature 签名

export declare const endsWith: (searchString: string, position?: number | undefined) => (s: string) => boolean

Example 例子

import * as S from 'fp-ts/string'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe('abc', S.endsWith('c')), true)
assert.deepStrictEqual(pipe('ab', S.endsWith('c')), false)

Added in v2.11.0 v2.11.0 中添加

includes   包括

Signature 签名

export declare const includes: (searchString: string, position?: number | undefined) => (s: string) => boolean

Example 例子

import * as S from 'fp-ts/string'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe('abc', S.includes('b')), true)
assert.deepStrictEqual(pipe('abc', S.includes('d')), false)

Added in v2.11.0 v2.11.0 中添加

isEmpty   是空的

Test whether a string is empty.
测试 string 是否为空。

Signature 签名

export declare const isEmpty: (s: string) => boolean

Example 例子

import * as S from 'fp-ts/string'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe('', S.isEmpty), true)
assert.deepStrictEqual(pipe('a', S.isEmpty), false)

Added in v2.10.0 v2.10.0 中添加

replace   代替

Signature 签名

export declare const replace: (searchValue: string | RegExp, replaceValue: string) => (s: string) => string

Example 例子

import * as S from 'fp-ts/string'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe('abc', S.replace('b', 'd')), 'adc')

Added in v2.11.0 v2.11.0 中添加

size   尺寸

Calculate the number of characters in a string.
计算 string 中的字符数。

Signature 签名

export declare const size: (s: string) => number

Example 例子

import * as S from 'fp-ts/string'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe('abc', S.size), 3)

Added in v2.10.0 v2.10.0 中添加

slice  

Signature 签名

export declare const slice: (start: number, end: number) => (s: string) => string

Example 例子

import * as S from 'fp-ts/string'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe('abcd', S.slice(1, 3)), 'bc')

Added in v2.11.0 v2.11.0 中添加

split   分裂

Signature 签名

export declare const split: (separator: string | RegExp) => (s: string) => ReadonlyNonEmptyArray<string>

Example 例子

import * as S from 'fp-ts/string'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe('abc', S.split('')), ['a', 'b', 'c'])
assert.deepStrictEqual(pipe('', S.split('')), [''])

Added in v2.11.0 v2.11.0 中添加

startsWith   以。。开始

Signature 签名

export declare const startsWith: (searchString: string, position?: number | undefined) => (s: string) => boolean

Example 例子

import * as S from 'fp-ts/string'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe('abc', S.startsWith('a')), true)
assert.deepStrictEqual(pipe('bc', S.startsWith('a')), false)

Added in v2.11.0 v2.11.0 中添加

toLowerCase   转为小写

Signature 签名

export declare const toLowerCase: (s: string) => string

Example 例子

import * as S from 'fp-ts/string'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe('A', S.toLowerCase), 'a')

Added in v2.11.0 v2.11.0 中添加

toUpperCase   改为大写

Signature 签名

export declare const toUpperCase: (s: string) => string

Example 例子

import * as S from 'fp-ts/string'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe('a', S.toUpperCase), 'A')

Added in v2.11.0 v2.11.0 中添加

trim   修剪

Signature 签名

export declare const trim: (s: string) => string

Example 例子

import * as S from 'fp-ts/string'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe(' a ', S.trim), 'a')

Added in v2.11.0 v2.11.0 中添加

trimLeft   向左修剪

Signature 签名

export declare const trimLeft: (s: string) => string

Example 例子

import * as S from 'fp-ts/string'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe(' a ', S.trimLeft), 'a ')

Added in v2.11.0 v2.11.0 中添加

trimRight   右修剪

Signature 签名

export declare const trimRight: (s: string) => string

Example 例子

import * as S from 'fp-ts/string'
import { pipe } from 'fp-ts/function'

assert.deepStrictEqual(pipe(' a ', S.trimRight), ' a')

Added in v2.11.0 v2.11.0 中添加

Strong overview  强概览

The Strong class extends Profunctor with combinators for working with product types.
Strong 类使用组合器扩展了 Profunctor ,以处理产品类型。

first and second lift values in a Profunctor to act on the first and second components of a tuple, respectively.
firstsecond 提升 Profunctor 中的值,分别作用于元组的第一个和第二个组件。

Another way to think about Strong is to piggyback on the intuition of inputs and outputs. Rewriting the type signature in this light then yields:
思考 Strong 的另一种方式是依靠输入和输出的直觉。从这个角度重写类型签名会产生:

first ::  forall input output a. p input output -> p (Tuple input a) (Tuple output a)
second :: forall input output a. p input output -> p (Tuple a input) (Tuple a output)

If we specialize the profunctor p to the function arrow, we get the following type signatures, which may look a bit more familiar:
如果我们将函子 p 专门化为函数箭头,我们会得到以下类型签名,这可能看起来更熟悉一些:

first ::  forall input output a. (input -> output) -> (Tuple input a) -> (Tuple output a)
second :: forall input output a. (input -> output) -> (Tuple a input) -> (Tuple a output)

So, when the profunctor is Function application, first essentially applies your function to the first element of a tuple, and second applies it to the second element (same as map would do).
因此,当 profunctorFunction 应用程序时, first 本质上将您的函数应用于元组的第一个元素, second 将其应用于第二个元素(与 map 的操作相同)。

Adapted from https://github.com/purescript/purescript-profunctor/blob/master/src/Data/Profunctor/Strong.purs
改编自https://github.com/purescript/purescript-profunctor/blob/master/src/Data/Profunctor/Strong.purs

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Strong (interface)   强(接口)

Signature 签名

export interface Strong<F> extends Profunctor<F> {
  readonly first: <A, B, C>(pab: HKT2<F, A, B>) => HKT2<F, [A, C], [B, C]>
  readonly second: <A, B, C>(pab: HKT2<F, B, C>) => HKT2<F, [A, B], [A, C]>
}

Added in v2.0.0 v2.0.0 中添加

Strong2 (interface)   强2(界面)

Signature 签名

export interface Strong2<F extends URIS2> extends Profunctor2<F> {
  readonly first: <A, B, C>(pab: Kind2<F, A, B>) => Kind2<F, [A, C], [B, C]>
  readonly second: <A, B, C>(pab: Kind2<F, B, C>) => Kind2<F, [A, B], [A, C]>
}

Added in v2.0.0 v2.0.0 中添加

Strong3 (interface)   强3(界面)

Signature 签名

export interface Strong3<F extends URIS3> extends Profunctor3<F> {
  readonly first: <R, A, B, C>(pab: Kind3<F, R, A, B>) => Kind3<F, R, [A, C], [B, C]>
  readonly second: <R, A, B, C>(pab: Kind3<F, R, B, C>) => Kind3<F, R, [A, B], [A, C]>
}

Added in v2.0.0 v2.0.0 中添加

Strong4 (interface)   Strong4(界面)

Signature 签名

export interface Strong4<F extends URIS4> extends Profunctor4<F> {
  readonly first: <S, R, A, B, C>(pab: Kind4<F, S, R, A, B>) => Kind4<F, S, R, [A, C], [B, C]>
  readonly second: <S, R, A, B, C>(pab: Kind4<F, S, R, B, C>) => Kind4<F, S, R, [A, B], [A, C]>
}

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

fanOut   扇出

Compose a value which introduces a tuple from two values, each introducing one side of the tuple.
组成一个由两个值引入元组的值,每个值引入元组的一侧。

This combinator is useful when assembling values from smaller components, because it provides a way to support two different types of output.
当从较小的组件组​​装值时,此组合器非常有用,因为它提供了一种支持两种不同类型输出的方法。

Specializing fanOut to function application would look like this:
fanOut 专门化为函数应用程序将如下所示:

fanOut :: forall a b c. (a -> b) -> (a -> c) -> (a -> (Tuple b c))

We take two functions, f and g, with the same parameter type and we transform them into a single function which takes one parameter and returns a tuple of the results of running f and g on the parameter, respectively. This allows us to run two parallel computations on the same input and return both results in a tuple.
我们采用两个具有相同参数类型的函数 fg ,并将它们转换为单个函数,该函数采用一个参数并返回在参数上运行 fg 结果的元组,分别。这允许我们对同一输入运行两个并行计算,并以元组形式返回两个结果。

Signature 签名

export declare function fanOut<F extends URIS4>(
  S: Strong4<F>,
  C: Category4<F>
): <S, R, A, B, C>(pab: Kind4<F, S, R, A, B>, pac: Kind4<F, S, R, A, C>) => Kind4<F, S, R, A, [B, C]>
export declare function fanOut<F extends URIS3>(
  S: Strong3<F>,
  C: Category3<F>
): <R, A, B, C>(pab: Kind3<F, R, A, B>, pac: Kind3<F, R, A, C>) => Kind3<F, R, A, [B, C]>
export declare function fanOut<F extends URIS2>(
  S: Strong2<F>,
  C: Category2<F>
): <A, B, C>(pab: Kind2<F, A, B>, pac: Kind2<F, A, C>) => Kind2<F, A, [B, C]>
export declare function fanOut<F>(
  S: Strong<F>,
  C: Category<F>
): <A, B, C>(pab: HKT2<F, A, B>, pac: HKT2<F, A, C>) => HKT2<F, A, [B, C]>

Added in v2.10.0 v2.10.0 中添加

split   分裂

Compose a value acting on a tuple from two values, each acting on one of the components of the tuple.
由两个值组成一个作用于元组的值,每个值作用于元组的一个组件。

Specializing split to function application would look like this:
split 专门化为函数应用程序将如下所示:

split :: forall a b c d. (a -> b) -> (c -> d) -> (Tuple a c) -> (Tuple b d)

We take two functions, f and g, and we transform them into a single function which takes a tuple and maps f over the first element and g over the second. Just like bi-map would do for the bi-functor instance of tuple.
我们采用两个函数 fg ,并将它们转换为单个函数,该函数采用一个元组并将 f 映射到第一个元素,将 g 映射到第二个元素。就像 bi-map 对元组的 bi-functor 实例所做的那样。

Signature 签名

export declare function split<F extends URIS4>(
  S: Strong4<F>,
  C: Category4<F>
): <S, R, A, B, C, D>(pab: Kind4<F, S, R, A, B>, pcd: Kind4<F, S, R, C, D>) => Kind4<F, S, R, [A, C], [B, D]>
export declare function split<F extends URIS3>(
  S: Strong3<F>,
  C: Category3<F>
): <R, A, B, C, D>(pab: Kind3<F, R, A, B>, pcd: Kind3<F, R, C, D>) => Kind3<F, R, [A, C], [B, D]>
export declare function split<F extends URIS2>(
  S: Strong2<F>,
  C: Category2<F>
): <A, B, C, D>(pab: Kind2<F, A, B>, pcd: Kind2<F, C, D>) => Kind2<F, [A, C], [B, D]>
export declare function split<F>(
  S: Strong<F>,
  C: Category<F>
): <A, B, C, D>(pab: HKT2<F, A, B>, pcd: HKT2<F, C, D>) => HKT2<F, [A, C], [B, D]>

Added in v2.10.0 v2.10.0 中添加

zone of death
死亡地带

fanout 扇出

Use fanOut instead. 请改用 fanOut

Signature 签名

export declare function fanout<F extends URIS4>(
  F: Category4<F> & Strong4<F>
): <S, R, A, B, C>(pab: Kind4<F, S, R, A, B>, pac: Kind4<F, S, R, A, C>) => Kind4<F, S, R, A, [B, C]>
export declare function fanout<F extends URIS3>(
  F: Category3<F> & Strong3<F>
): <R, A, B, C>(pab: Kind3<F, R, A, B>, pac: Kind3<F, R, A, C>) => Kind3<F, R, A, [B, C]>
export declare function fanout<F extends URIS2>(
  F: Category2<F> & Strong2<F>
): <A, B, C>(pab: Kind2<F, A, B>, pac: Kind2<F, A, C>) => Kind2<F, A, [B, C]>
export declare function fanout<F>(
  F: Category<F> & Strong<F>
): <A, B, C>(pab: HKT2<F, A, B>, pac: HKT2<F, A, C>) => HKT2<F, A, [B, C]>

Added in v2.0.0 v2.0.0 中添加

splitStrong 分裂强

Use split instead. 请改用 split

Signature 签名

export declare function splitStrong<F extends URIS4>(
  F: Category4<F> & Strong4<F>
): <S, R, A, B, C, D>(pab: Kind4<F, S, R, A, B>, pcd: Kind4<F, S, R, C, D>) => Kind4<F, S, R, [A, C], [B, D]>
export declare function splitStrong<F extends URIS3>(
  F: Category3<F> & Strong3<F>
): <R, A, B, C, D>(pab: Kind3<F, R, A, B>, pcd: Kind3<F, R, C, D>) => Kind3<F, R, [A, C], [B, D]>
export declare function splitStrong<F extends URIS2>(
  F: Category2<F> & Strong2<F>
): <A, B, C, D>(pab: Kind2<F, A, B>, pcd: Kind2<F, C, D>) => Kind2<F, [A, C], [B, D]>
export declare function splitStrong<F>(
  F: Category<F> & Strong<F>
): <A, B, C, D>(pab: HKT2<F, A, B>, pcd: HKT2<F, C, D>) => HKT2<F, [A, C], [B, D]>

Added in v2.0.0 v2.0.0 中添加

struct overview  结构概述

Added in v2.10.0 v2.10.0 中添加


Table of contents
目录


instances   实例

getAssignSemigroup   获取分配半群

Return a semigroup which works like Object.assign.
返回一个半群,其作用类似于 Object.assign

Signature 签名

export declare const getAssignSemigroup: <A extends object = never>() => Semigroup<A>

Example 例子

import { getAssignSemigroup } from 'fp-ts/struct'

interface Person {
  readonly name: string
  readonly age: number
}

const S = getAssignSemigroup<Person>()
assert.deepStrictEqual(S.concat({ name: 'name', age: 23 }, { name: 'name', age: 24 }), { name: 'name', age: 24 })

Added in v2.10.0 v2.10.0 中添加

utils   实用程序

evolve   发展

Creates a new object by recursively evolving a shallow copy of a, according to the transformation functions.
根据 transformation 函数,通过递归演化 a 的浅拷贝来创建新对象。

Signature 签名

export declare const evolve: <A, F extends { [K in keyof A]: (a: A[K]) => unknown }>(
  transformations: F
) => (a: A) => { [K in keyof F]: ReturnType<F[K]> }

Example 例子

import { pipe } from 'fp-ts/function'
import { evolve } from 'fp-ts/struct'

assert.deepStrictEqual(
  pipe(
    { a: 'a', b: 1 },
    evolve({
      a: (a) => a.length,
      b: (b) => b * 2,
    })
  ),
  { a: 1, b: 2 }
)

Added in v2.11.0 v2.11.0 中添加

Task overview  任务概述

interface Task<A> {
  (): Promise<A>
}

Task<A> represents an asynchronous computation that yields a value of type A and never fails. If you want to represent an asynchronous computation that may fail, please see TaskEither.
Task<A> 表示异步计算,产生 A 类型的值并且永远不会失败。如果你想表示一个可能失败的异步计算,请参见 TaskEither

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


combinators   组合器

tap   轻敲

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tap: {
  <A, _>(self: Task<A>, f: (a: A) => Task<_>): Task<A>
  <A, _>(f: (a: A) => Task<_>): (self: Task<A>) => Task<A>
}

Added in v2.15.0 v2.15.0 中添加

tapIO   tapIO

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapIO: {
  <A, _>(f: (a: A) => IO<_>): (self: Task<A>) => Task<A>
  <A, _>(self: Task<A>, f: (a: A) => IO<_>): Task<A>
}

Example 例子

import { pipe } from 'fp-ts/function'
import * as T from 'fp-ts/Task'
import * as Console from 'fp-ts/Console'

// Will produce `Hello, fp-ts` to the stdout
const effect = pipe(
  T.of('fp-ts'),
  T.tapIO((value) => Console.log(`Hello, ${value}`))
)

async function test() {
  assert.deepStrictEqual(await effect(), 'fp-ts')
}

test()

Added in v2.16.0 v2.16.0 中添加

constructors  构造函数

of  

Signature 签名

export declare const of: <A>(a: A) => Task<A>

Added in v2.0.0 v2.0.0 中添加

conversions   转换

fromIO   来自IO

Signature 签名

export declare const fromIO: <A>(fa: IO<A>) => Task<A>

Added in v2.0.0 v2.0.0 中添加

do notation   做记号

Do  

Signature 签名

export declare const Do: Task<{}>

Added in v2.9.0 v2.9.0中添加

apS   apS

Signature 签名

export declare const apS: <N, A, B>(
  name: Exclude<N, keyof A>,
  fb: Task<B>
) => (fa: Task<A>) => Task<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bind   绑定

Signature 签名

export declare const bind: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => Task<B>
) => (ma: Task<A>) => Task<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bindTo   绑定到

Signature 签名

export declare const bindTo: <N>(name: N) => <A>(fa: Task<A>) => Task<{ readonly [K in N]: A }>

Added in v2.8.0 v2.8.0 中添加

let  

Signature 签名

export declare const let: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => (fa: Task<A>) => Task<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.13.0 v2.13.0 中添加

instances   实例

ApplicativePar   应用性参数

Runs computations in parallel.
并行运行计算。

Signature 签名

export declare const ApplicativePar: Applicative1<'Task'>

Added in v2.7.0 v2.7.0 中添加

ApplicativeSeq   应用序列

Runs computations sequentially.
按顺序运行计算。

Signature 签名

export declare const ApplicativeSeq: Applicative1<'Task'>

Added in v2.7.0 v2.7.0 中添加

ApplyPar   申请帕

Runs computations in parallel.
并行运行计算。

Signature 签名

export declare const ApplyPar: Apply1<'Task'>

Added in v2.10.0 v2.10.0 中添加

ApplySeq   应用序列

Runs computations sequentially.
按顺序运行计算。

Signature 签名

export declare const ApplySeq: Apply1<'Task'>

Added in v2.10.0 v2.10.0 中添加

Chain  

Signature 签名

export declare const Chain: chainable.Chain1<'Task'>

Added in v2.10.0 v2.10.0 中添加

FromIO   来自IO

Signature 签名

export declare const FromIO: FromIO1<'Task'>

Added in v2.10.0 v2.10.0 中添加

FromTask   来自任务

Signature 签名

export declare const FromTask: FromTask1<'Task'>

Added in v2.10.0 v2.10.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor1<'Task'>

Added in v2.7.0 v2.7.0 中添加

Monad   单子

Signature 签名

export declare const Monad: Monad1<'Task'>

Added in v2.10.0 v2.10.0 中添加

MonadIO   莫纳德奥

Signature 签名

export declare const MonadIO: MonadIO1<'Task'>

Added in v2.10.0 v2.10.0 中添加

MonadTask  单子任务

Signature 签名

export declare const MonadTask: MonadTask1<'Task'>

Added in v2.10.0 v2.10.0 中添加

Pointed  

Signature 签名

export declare const Pointed: Pointed1<'Task'>

Added in v2.10.0 v2.10.0 中添加

getRaceMonoid   获取RaceMonoid

Monoid returning the first completed task.
Monoid 返回第一个完成的任务。

Note: uses Promise.race internally.
注意:内部使用 Promise.race

Signature 签名

export declare function getRaceMonoid<A = never>(): Monoid<Task<A>>

Example 例子

import * as T from 'fp-ts/Task'

async function test() {
  const S = T.getRaceMonoid<string>()
  const fa = T.delay(20)(T.of('a'))
  const fb = T.delay(10)(T.of('b'))
  assert.deepStrictEqual(await S.concat(fa, fb)(), 'b')
}

test()

Added in v2.0.0 v2.0.0 中添加

legacy   遗产

chain  

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chain: <A, B>(f: (a: A) => Task<B>) => (ma: Task<A>) => Task<B>

Added in v2.0.0 v2.0.0 中添加

chainFirst   链优先

Alias of tap.  tap 的别名。

Signature 签名

export declare const chainFirst: <A, B>(f: (a: A) => Task<B>) => (first: Task<A>) => Task<A>

Added in v2.0.0 v2.0.0 中添加

chainFirstIOK  链第一IOK

Alias of tapIO.  tapIO 的别名。

Signature 签名

export declare const chainFirstIOK: <A, B>(f: (a: A) => IO<B>) => (first: Task<A>) => Task<A>

Added in v2.10.0 v2.10.0 中添加

chainIOK  链IOK

Alias of flatMapIO.  flatMapIO 的别名。

Signature 签名

export declare const chainIOK: <A, B>(f: (a: A) => IO<B>) => (first: Task<A>) => Task<B>

Added in v2.4.0 v2.4.0中添加

lifting   起重

fromIOK   来自IOK

Signature 签名

export declare const fromIOK: <A extends readonly unknown[], B>(f: (...a: A) => IO<B>) => (...a: A) => Task<B>

Added in v2.4.0 v2.4.0中添加

mapping   映射

as   作为

Maps the value to the specified constant value.
将值映射到指定的常量值。

Signature 签名

export declare const as: { <A>(a: A): <_>(self: Task<_>) => Task<A>; <_, A>(self: Task<_>, a: A): Task<A> }

Added in v2.16.0 v2.16.0 中添加

asUnit   作为单位

Maps the value to the void constant value.
将值映射到 void 常量值。

Signature 签名

export declare const asUnit: <_>(self: Task<_>) => Task<void>

Added in v2.16.0 v2.16.0 中添加

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <B>(fab: Task<(a: A) => B>) => Task<B>

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => (fa: Task<A>) => Task<B>

Added in v2.0.0 v2.0.0 中添加

model   模型

Task (interface)   任务(界面)

Signature 签名

export interface Task<A> {
  (): Promise<A>
}

Added in v2.0.0 v2.0.0 中添加

sequencing   测序

flatMap   平面地图

Signature 签名

export declare const flatMap: {
  <A, B>(f: (a: A) => Task<B>): (ma: Task<A>) => Task<B>
  <A, B>(ma: Task<A>, f: (a: A) => Task<B>): Task<B>
}

Added in v2.14.0 v2.14.0 中添加

flatMapIO   平面MapIO

Signature 签名

export declare const flatMapIO: {
  <A, B>(f: (a: A) => IO<B>): (self: Task<A>) => Task<B>
  <A, B>(self: Task<A>, f: (a: A) => IO<B>): Task<B>
}

Added in v2.16.0 v2.16.0 中添加

flatten   压扁

Signature 签名

export declare const flatten: <A>(mma: Task<Task<A>>) => Task<A>

Added in v2.0.0 v2.0.0 中添加

traversing   穿越

sequenceArray   序列数组

Equivalent to ReadonlyArray#sequence(Applicative). 相当于 ReadonlyArray#sequence(Applicative)

Signature 签名

export declare const sequenceArray: <A>(arr: readonly Task<A>[]) => Task<readonly A[]>

Added in v2.9.0 v2.9.0中添加

sequenceSeqArray   序列SeqArray

Equivalent to ReadonlyArray#sequence(ApplicativeSeq). 相当于 ReadonlyArray#sequence(ApplicativeSeq)

Signature 签名

export declare const sequenceSeqArray: <A>(arr: readonly Task<A>[]) => Task<readonly A[]>

Added in v2.9.0 v2.9.0中添加

traverseArray   遍历数组

Equivalent to ReadonlyArray#traverse(Applicative). 相当于 ReadonlyArray#traverse(Applicative)

Signature 签名

export declare const traverseArray: <A, B>(f: (a: A) => Task<B>) => (as: readonly A[]) => Task<readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseArrayWithIndex   带索引遍历数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseArrayWithIndex: <A, B>(
  f: (index: number, a: A) => Task<B>
) => (as: readonly A[]) => Task<readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseReadonlyArrayWithIndex
遍历带索引的只读数组

Equivalent to ReadonlyArray#traverseWithIndex(ApplicativePar). 相当于 ReadonlyArray#traverseWithIndex(ApplicativePar)

Signature 签名

export declare const traverseReadonlyArrayWithIndex: <A, B>(
  f: (index: number, a: A) => Task<B>
) => (as: readonly A[]) => Task<readonly B[]>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyArrayWithIndexSeq
遍历ReadonlyArrayWithIndexSeq

Equivalent to ReadonlyArray#traverseWithIndex(ApplicativeSeq). 相当于 ReadonlyArray#traverseWithIndex(ApplicativeSeq)

Signature 签名

export declare const traverseReadonlyArrayWithIndexSeq: <A, B>(
  f: (index: number, a: A) => Task<B>
) => (as: readonly A[]) => Task<readonly B[]>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyNonEmptyArrayWithIndex
遍历ReadonlyNonEmptyArrayWithIndex

Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar). 相当于 ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar)

Signature 签名

export declare const traverseReadonlyNonEmptyArrayWithIndex: <A, B>(
  f: (index: number, a: A) => Task<B>
) => (as: ReadonlyNonEmptyArray<A>) => Task<ReadonlyNonEmptyArray<B>>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyNonEmptyArrayWithIndexSeq
遍历ReadonlyNonEmptyArrayWithIndexSeq

Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq). 相当于 ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq)

Signature 签名

export declare const traverseReadonlyNonEmptyArrayWithIndexSeq: <A, B>(
  f: (index: number, a: A) => Task<B>
) => (as: ReadonlyNonEmptyArray<A>) => Task<ReadonlyNonEmptyArray<B>>

Added in v2.11.0 v2.11.0 中添加

traverseSeqArray   遍历SeqArray

Equivalent to ReadonlyArray#traverse(ApplicativeSeq). 相当于 ReadonlyArray#traverse(ApplicativeSeq)

Signature 签名

export declare const traverseSeqArray: <A, B>(f: (a: A) => Task<B>) => (as: readonly A[]) => Task<readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseSeqArrayWithIndex
带索引的遍历SeqArray

Equivalent to ReadonlyArray#traverseWithIndex(ApplicativeSeq). 相当于 ReadonlyArray#traverseWithIndex(ApplicativeSeq)

Signature 签名

export declare const traverseSeqArrayWithIndex: <A, B>(
  f: (index: number, a: A) => Task<B>
) => (as: readonly A[]) => Task<readonly B[]>

Added in v2.9.0 v2.9.0中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'Task'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

ApT   易于

Signature 签名

export declare const ApT: Task<readonly []>

Added in v2.11.0 v2.11.0 中添加

ap   美联社

Signature 签名

export declare const ap: <A>(fa: Task<A>) => <B>(fab: Task<(a: A) => B>) => Task<B>

Added in v2.0.0 v2.0.0 中添加

apFirst   应用程序第一

Combine two effectful actions, keeping only the result of the first.
结合两个有效的操作,仅保留第一个操作的结果。

Signature 签名

export declare const apFirst: <B>(second: Task<B>) => <A>(first: Task<A>) => Task<A>

Added in v2.0.0 v2.0.0 中添加

apSecond   ap秒

Combine two effectful actions, keeping only the result of the second.
结合两个有效的操作,只保留第二个的结果。

Signature 签名

export declare const apSecond: <B>(second: Task<B>) => <A>(first: Task<A>) => Task<B>

Added in v2.0.0 v2.0.0 中添加

delay   延迟

Creates a task that will complete after a time delay
创建一个将在一段时间延迟后完成的任务

Signature 签名

export declare function delay(millis: number): <A>(ma: Task<A>) => Task<A>

Example 例子

import { sequenceT } from 'fp-ts/Apply'
import * as T from 'fp-ts/Task'
import { takeRight } from 'fp-ts/Array'

async function test() {
  const log: Array<string> = []
  const append = (message: string): T.Task<void> =>
    T.fromIO(() => {
      log.push(message)
    })
  const fa = append('a')
  const fb = T.delay(20)(append('b'))
  const fc = T.delay(10)(append('c'))
  const fd = append('d')
  await sequenceT(T.ApplyPar)(fa, fb, fc, fd)()
  assert.deepStrictEqual(takeRight(2)(log), ['c', 'b'])
}

test()

Added in v2.0.0 v2.0.0 中添加

never   绝不

A Task that never completes.
一个永远不会完成的 Task

Signature 签名

export declare const never: Task<never>

Added in v2.0.0 v2.0.0 中添加

zone of death
死亡地带

fromTask 来自任务

Signature 签名

export declare const fromTask: <A>(fa: Task<A>) => Task<A>

Added in v2.7.0 v2.7.0 中添加

getMonoid 获取Monoid

Use getApplicativeMonoid instead. 请改用 getApplicativeMonoid

Lift a monoid into ‘Task’, the inner values are concatenated using the provided Monoid.
将一个幺半群提升到“任务”中,内部值使用提供的 Monoid 连接起来。

Signature 签名

export declare const getMonoid: <A>(M: Monoid<A>) => Monoid<Task<A>>

Added in v2.0.0 v2.0.0 中添加

getSemigroup 获取半群

Use getApplySemigroup instead. 请改用 getApplySemigroup

Signature 签名

export declare const getSemigroup: <A>(S: Semigroup<A>) => Semigroup<Task<A>>

Added in v2.0.0 v2.0.0 中添加

taskSeq 任务序列

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass T.Functor instead of T.taskSeq (where T is from import T from 'fp-ts/Task')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 T.Functor 而不是 T.taskSeq (其中 T 来自 import T from 'fp-ts/Task'

Signature 签名

export declare const taskSeq: Monad1<'Task'> & MonadTask1<'Task'>

Added in v2.0.0 v2.0.0 中添加

task 任务

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass T.Functor instead of T.task (where T is from import T from 'fp-ts/Task')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 T.Functor 而不是 T.task (其中 T 来自 import T from 'fp-ts/Task'

Signature 签名

export declare const task: Monad1<'Task'> & MonadTask1<'Task'>

Added in v2.0.0 v2.0.0 中添加

TaskEither overview  任务任一概述

interface TaskEither<E, A> extends Task<Either<E, A>> {}

TaskEither<E, A> represents an asynchronous computation that either yields a value of type A or fails yielding an error of type E. If you want to represent an asynchronous computation that never fails, please see Task.
TaskEither<E, A> 表示异步计算,它要么生成 A 类型的值,要么失败并生成 E 类型的错误。如果你想表示一个永不失败的异步计算,请参阅 Task

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


combinators   组合器

tap   轻敲

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tap: {
  <E1, A, E2, _>(self: TaskEither<E1, A>, f: (a: A) => TaskEither<E2, _>): TaskEither<E1 | E2, A>
  <A, E2, _>(f: (a: A) => TaskEither<E2, _>): <E1>(self: TaskEither<E1, A>) => TaskEither<E2 | E1, A>
}

Added in v2.15.0 v2.15.0 中添加

tapEither   点击任一

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapEither: {
  <A, E2, _>(f: (a: A) => E.Either<E2, _>): <E1>(self: TaskEither<E1, A>) => TaskEither<E2 | E1, A>
  <E1, A, E2, _>(self: TaskEither<E1, A>, f: (a: A) => E.Either<E2, _>): TaskEither<E1 | E2, A>
}

Example 例子

import * as E from 'fp-ts/Either'
import { pipe } from 'fp-ts/function'
import * as TE from 'fp-ts/TaskEither'

const checkString = (value: string) =>
  pipe(
    TE.of(value),
    TE.tapEither(() => (value.length > 0 ? E.right('ok') : E.left('error')))
  )

async function test() {
  assert.deepStrictEqual(await checkString('')(), E.left('error'))
  assert.deepStrictEqual(await checkString('fp-ts')(), E.right('fp-ts'))
}

test()

Added in v2.16.0 v2.16.0 中添加

tapIO   tapIO

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapIO: {
  <A, _>(f: (a: A) => IO<_>): <E>(self: TaskEither<E, A>) => TaskEither<E, A>
  <E, A, _>(self: TaskEither<E, A>, f: (a: A) => IO<_>): TaskEither<E, A>
}

Example 例子

import { pipe } from 'fp-ts/function'
import * as TE from 'fp-ts/TaskEither'
import * as E from 'fp-ts/Either'
import * as Console from 'fp-ts/Console'

// Will produce `Hello, fp-ts` to the stdout
const effectA = TE.tapIO(TE.of(1), (value) => Console.log(`Hello, ${value}`))

// No output to the stdout
const effectB = pipe(
  TE.left('error'),
  TE.tapIO((value) => Console.log(`Hello, ${value}`))
)

async function test() {
  assert.deepStrictEqual(await effectA(), E.of(1))
  assert.deepStrictEqual(await effectB(), E.left('error'))
}

test()

Added in v2.16.0 v2.16.0 中添加

tapTask   点击任务

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapTask: {
  <A, _>(f: (a: A) => T.Task<_>): <E>(self: TaskEither<E, A>) => TaskEither<E, A>
  <E, A, _>(self: TaskEither<E, A>, f: (a: A) => T.Task<_>): TaskEither<E, A>
}

Example 例子

import * as TE from 'fp-ts/TaskEither'
import * as T from 'fp-ts/Task'
import * as E from 'fp-ts/Either'

const effect = TE.tapIO(TE.of(1), (value) => T.of(value + 1))

async function test() {
  assert.deepStrictEqual(await effect(), E.of(1))
}

test()

Added in v2.16.0 v2.16.0 中添加

constructors  构造函数

left  左边

Signature 签名

export declare const left: <E = never, A = never>(e: E) => TaskEither<E, A>

Added in v2.0.0 v2.0.0 中添加

leftIO   左IO

Signature 签名

export declare const leftIO: <E = never, A = never>(me: IO<E>) => TaskEither<E, A>

Added in v2.0.0 v2.0.0 中添加

leftTask   左任务

Signature 签名

export declare const leftTask: <E = never, A = never>(me: T.Task<E>) => TaskEither<E, A>

Added in v2.0.0 v2.0.0 中添加

of  

Signature 签名

export declare const of: <E = never, A = never>(a: A) => TaskEither<E, A>

Added in v2.0.0 v2.0.0 中添加

Signature 签名

export declare const right: <E = never, A = never>(a: A) => TaskEither<E, A>

Added in v2.0.0 v2.0.0 中添加

rightIO   右IO

Signature 签名

export declare const rightIO: <E = never, A = never>(ma: IO<A>) => TaskEither<E, A>

Added in v2.0.0 v2.0.0 中添加

rightTask   正确的任务

Signature 签名

export declare const rightTask: <E = never, A = never>(ma: T.Task<A>) => TaskEither<E, A>

Added in v2.0.0 v2.0.0 中添加

conversions   转换

fromEither   来自任一

Signature 签名

export declare const fromEither: <E, A>(fa: E.Either<E, A>) => TaskEither<E, A>

Added in v2.0.0 v2.0.0 中添加

fromIO   来自IO

Signature 签名

export declare const fromIO: <A, E = never>(fa: IO<A>) => TaskEither<E, A>

Added in v2.7.0 v2.7.0 中添加

fromIOEither   来自IOEither

Signature 签名

export declare const fromIOEither: <E, A>(fa: IOEither<E, A>) => TaskEither<E, A>

Added in v2.0.0 v2.0.0 中添加

fromNullable   来自可为空的

Signature 签名

export declare const fromNullable: <E>(e: E) => <A>(a: A) => TaskEither<E, NonNullable<A>>

Added in v2.12.0 v2.12.0 中添加

fromOption   来自选项

Signature 签名

export declare const fromOption: <E>(onNone: LazyArg<E>) => <A>(fa: Option<A>) => TaskEither<E, A>

Added in v2.0.0 v2.0.0 中添加

fromTask   来自任务

Signature 签名

export declare const fromTask: <A, E = never>(fa: T.Task<A>) => TaskEither<E, A>

Added in v2.7.0 v2.7.0 中添加

fromTaskOption   来自任务选项

Signature 签名

export declare const fromTaskOption: <E>(onNone: LazyArg<E>) => <A>(fa: TaskOption<A>) => TaskEither<E, A>

Added in v2.11.0 v2.11.0 中添加

toUnion   至联盟

Signature 签名

export declare const toUnion: <E, A>(fa: TaskEither<E, A>) => T.Task<E | A>

Added in v2.10.0 v2.10.0 中添加

do notation   做记号

Do  

Signature 签名

export declare const Do: TaskEither<never, {}>

Added in v2.9.0 v2.9.0中添加

apS   apS

Signature 签名

export declare const apS: <N, A, E, B>(
  name: Exclude<N, keyof A>,
  fb: TaskEither<E, B>
) => (fa: TaskEither<E, A>) => TaskEither<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

apSW   apSW

Less strict version of apS.
apS 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const apSW: <A, N extends string, E2, B>(
  name: Exclude<N, keyof A>,
  fb: TaskEither<E2, B>
) => <E1>(fa: TaskEither<E1, A>) => TaskEither<E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bind   绑定

Signature 签名

export declare const bind: <N, A, E, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => TaskEither<E, B>
) => (ma: TaskEither<E, A>) => TaskEither<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bindTo   绑定到

Signature 签名

export declare const bindTo: <N>(name: N) => <E, A>(fa: TaskEither<E, A>) => TaskEither<E, { readonly [K in N]: A }>

Added in v2.8.0 v2.8.0 中添加

bindW   绑定W

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const bindW: <N extends string, A, E2, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => TaskEither<E2, B>
) => <E1>(fa: TaskEither<E1, A>) => TaskEither<E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

let  

Signature 签名

export declare const let: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => <E>(fa: TaskEither<E, A>) => TaskEither<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.13.0 v2.13.0 中添加

error handling   错误处理

alt   替代

Identifies an associative operation on a type constructor. It is similar to Semigroup, except that it applies to types of kind * -> *.
标识类型构造函数上的关联操作。它与 Semigroup 类似,但它适用于 * -> * 类型。

In case of TaskEither returns fa if is a Right or the value returned by that otherwise.
如果是 TaskEither ,则返回 fa (如果是 Right ),否则返回 that 返回的值。

See also orElse. 另请参见 orElse。

Signature 签名

export declare const alt: <E, A>(that: LazyArg<TaskEither<E, A>>) => (fa: TaskEither<E, A>) => TaskEither<E, A>

Example 例子

import * as E from 'fp-ts/Either'
import { pipe } from 'fp-ts/function'
import * as TE from 'fp-ts/TaskEither'

async function test() {
  assert.deepStrictEqual(
    await pipe(
      TE.right(1),
      TE.alt(() => TE.right(2))
    )(),
    E.right(1)
  )
  assert.deepStrictEqual(
    await pipe(
      TE.left('a'),
      TE.alt(() => TE.right(2))
    )(),
    E.right(2)
  )
  assert.deepStrictEqual(
    await pipe(
      TE.left('a'),
      TE.alt(() => TE.left('b'))
    )(),
    E.left('b')
  )
}

test()

Added in v2.0.0 v2.0.0 中添加

altW   替代W

Less strict version of alt.
alt 的不太严格版本。

The W suffix (short for Widening) means that the error and the return types will be merged.
W 后缀(Widening 的缩写)意味着错误和返回类型将被合并。

Signature 签名

export declare const altW: <E2, B>(
  that: LazyArg<TaskEither<E2, B>>
) => <E1, A>(fa: TaskEither<E1, A>) => TaskEither<E2, B | A>

Added in v2.9.0 v2.9.0中添加

getAltTaskValidation   获取AltTaskValidation

The default Alt instance returns the last error, if you want to get all errors you need to provide a way to concatenate them via a Semigroup.
默认的 Alt 实例返回最后一个错误,如果你想获取所有错误,你需要提供一种通过 Semigroup 连接它们的方法。

See getAltValidation. 请参阅 getAltValidation

Signature 签名

export declare function getAltTaskValidation<E>(S: Semigroup<E>): Alt2C<URI, E>

Added in v2.7.0 v2.7.0 中添加

getApplicativeTaskValidation
获取应用任务验证

The default ApplicativePar instance returns the first error, if you want to get all errors you need to provide a way to concatenate them via a Semigroup.
默认的 ApplicativePar 实例返回第一个错误,如果您想获取所有错误,您需要提供一种通过 Semigroup 连接它们的方法。

Signature 签名

export declare function getApplicativeTaskValidation<E>(A: Apply1<T.URI>, S: Semigroup<E>): Applicative2C<URI, E>

Example 例子

import * as E from 'fp-ts/Either'
import { pipe } from 'fp-ts/function'
import * as RA from 'fp-ts/ReadonlyArray'
import * as S from 'fp-ts/Semigroup'
import * as string from 'fp-ts/string'
import * as T from 'fp-ts/Task'
import * as TE from 'fp-ts/TaskEither'

interface User {
  readonly id: string
  readonly name: string
}

const remoteDatabase: ReadonlyArray<User> = [
  { id: 'id1', name: 'John' },
  { id: 'id2', name: 'Mary' },
  { id: 'id3', name: 'Joey' },
]

const fetchUser = (id: string): TE.TaskEither<string, User> =>
  pipe(
    remoteDatabase,
    RA.findFirst((user) => user.id === id),
    TE.fromOption(() => `${id} not found`)
  )

async function test() {
  assert.deepStrictEqual(
    await pipe(['id4', 'id5'], RA.traverse(TE.ApplicativePar)(fetchUser))(),
    E.left('id4 not found') // <= first error
  )

  const Applicative = TE.getApplicativeTaskValidation(T.ApplyPar, pipe(string.Semigroup, S.intercalate(', ')))

  assert.deepStrictEqual(
    await pipe(['id4', 'id5'], RA.traverse(Applicative)(fetchUser))(),
    E.left('id4 not found, id5 not found') // <= all errors
  )
}

test()

Added in v2.7.0 v2.7.0 中添加

getOrElse  获取或否则

Signature 签名

export declare const getOrElse: <E, A>(onLeft: (e: E) => T.Task<A>) => (ma: TaskEither<E, A>) => T.Task<A>

Added in v2.0.0 v2.0.0 中添加

getOrElseW   获取或否则W

Less strict version of getOrElse.
getOrElse 的不太严格版本。

The W suffix (short for Widening) means that the handler return type will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const getOrElseW: <E, B>(onLeft: (e: E) => T.Task<B>) => <A>(ma: TaskEither<E, A>) => T.Task<B | A>

Added in v2.6.0 v2.6.0 中添加

mapBoth   地图两者

Returns a TaskEither whose failure and success channels have been mapped by the specified pair of functions, f and g.
返回一个 TaskEither ,其失败和成功通道已由指定的函数对 fg 映射。

Signature 签名

export declare const mapBoth: {
  <E, G, A, B>(f: (e: E) => G, g: (a: A) => B): (self: TaskEither<E, A>) => TaskEither<G, B>
  <E, A, G, B>(self: TaskEither<E, A>, f: (e: E) => G, g: (a: A) => B): TaskEither<G, B>
}

Example 例子

import * as TaskEither from 'fp-ts/TaskEither'
import * as Either from 'fp-ts/Either'

const f = (s: string) => new Error(s)
const g = (n: number) => n * 2

async function test() {
  assert.deepStrictEqual(await TaskEither.mapBoth(TaskEither.right(1), f, g)(), Either.right(2))
  assert.deepStrictEqual(await TaskEither.mapBoth(TaskEither.left('err'), f, g)(), Either.left(new Error('err')))
}

test()

Added in v2.16.0 v2.16.0 中添加

mapError   地图错误

Returns a TaskEither with its error channel mapped using the specified function.
返回 TaskEither 及其使用指定函数映射的错误通道。

Signature 签名

export declare const mapError: {
  <E, G>(f: (e: E) => G): <A>(self: TaskEither<E, A>) => TaskEither<G, A>
  <E, A, G>(self: TaskEither<E, A>, f: (e: E) => G): TaskEither<G, A>
}

Example 例子

import * as TaskEither from 'fp-ts/TaskEither'
import * as Either from 'fp-ts/Either'

const f = (s: string) => new Error(s)

async function test() {
  assert.deepStrictEqual(await TaskEither.mapError(TaskEither.right(1), f)(), Either.right(1))
  assert.deepStrictEqual(await TaskEither.mapError(TaskEither.left('err'), f)(), Either.left(new Error('err')))
}

test()

Added in v2.16.0 v2.16.0 中添加

orElse   要不然

Returns ma if is a Right or the value returned by onLeft otherwise.
如果是 Right 则返回 ma ,否则返回 onLeft 返回的值。

See also alt. 另请参见替代。

Signature 签名

export declare const orElse: <E1, A, E2>(
  onLeft: (e: E1) => TaskEither<E2, A>
) => (ma: TaskEither<E1, A>) => TaskEither<E2, A>

Example 例子

import * as E from 'fp-ts/Either'
import { pipe } from 'fp-ts/function'
import * as TE from 'fp-ts/TaskEither'

async function test() {
  const errorHandler = TE.orElse((error: string) => TE.right(`recovering from ${error}...`))
  assert.deepStrictEqual(await pipe(TE.right('ok'), errorHandler)(), E.right('ok'))
  assert.deepStrictEqual(await pipe(TE.left('ko'), errorHandler)(), E.right('recovering from ko...'))
}

test()

Added in v2.0.0 v2.0.0 中添加

orElseFirstIOK   否则先IOK

Signature 签名

export declare const orElseFirstIOK: <E, B>(onLeft: (e: E) => IO<B>) => <A>(ma: TaskEither<E, A>) => TaskEither<E, A>

Added in v2.12.0 v2.12.0 中添加

orElseFirstTaskK   或者其他第一个任务K

Signature 签名

export declare const orElseFirstTaskK: <E, B>(
  onLeft: (e: E) => T.Task<B>
) => <A>(ma: TaskEither<E, A>) => TaskEither<E, A>

Added in v2.12.0 v2.12.0 中添加

orElseW   否则W

Less strict version of orElse.
orElse 的不太严格版本。

The W suffix (short for Widening) means that the return types will be merged.
W 后缀(Widening 的缩写)意味着返回类型将被合并。

Signature 签名

export declare const orElseW: <E1, E2, B>(
  onLeft: (e: E1) => TaskEither<E2, B>
) => <A>(ma: TaskEither<E1, A>) => TaskEither<E2, B | A>

Added in v2.10.0 v2.10.0 中添加

orLeft   或向左

Signature 签名

export declare const orLeft: <E1, E2>(onLeft: (e: E1) => T.Task<E2>) => <A>(fa: TaskEither<E1, A>) => TaskEither<E2, A>

Added in v2.11.0 v2.11.0 中添加

tapError   点击错误

Returns an effect that effectfully “peeks” at the failure of this effect.
返回一个效果,有效地“窥视”此效果的失败。

Signature 签名

export declare const tapError: {
  <E1, E2, _>(onLeft: (e: E1) => TaskEither<E2, _>): <A>(self: TaskEither<E1, A>) => TaskEither<E1 | E2, A>
  <E1, A, E2, _>(self: TaskEither<E1, A>, onLeft: (e: E1) => TaskEither<E2, _>): TaskEither<E1 | E2, A>
}

Added in v2.15.0 v2.15.0 中添加

filtering   过滤

filterOrElse  过滤器或者其他

Signature 签名

export declare const filterOrElse: {
  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: TaskEither<E, A>) => TaskEither<E, B>
  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(mb: TaskEither<E, B>) => TaskEither<E, B>
  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: TaskEither<E, A>) => TaskEither<E, A>
}

Added in v2.0.0 v2.0.0 中添加

filterOrElseW   过滤器否则W

Less strict version of filterOrElse.
filterOrElse 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const filterOrElseW: {
  <A, B extends A, E2>(refinement: Refinement<A, B>, onFalse: (a: A) => E2): <E1>(
    ma: TaskEither<E1, A>
  ) => TaskEither<E2 | E1, B>
  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <E1, B extends A>(
    mb: TaskEither<E1, B>
  ) => TaskEither<E2 | E1, B>
  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <E1>(ma: TaskEither<E1, A>) => TaskEither<E2 | E1, A>
}

Added in v2.9.0 v2.9.0中添加

getCompactable   获取可压缩的

Signature 签名

export declare const getCompactable: <E>(M: Monoid<E>) => Compactable2C<'TaskEither', E>

Added in v2.10.0 v2.10.0 中添加

getFilterable   获取可过滤的

Signature 签名

export declare function getFilterable<E>(M: Monoid<E>): Filterable2C<URI, E>

Added in v2.1.0 v2.1.0中添加

instances   实例

Alt   替代

Signature 签名

export declare const Alt: Alt2<'TaskEither'>

Added in v2.7.0 v2.7.0 中添加

ApplicativePar   应用性参数

Runs computations in parallel.
并行运行计算。

Signature 签名

export declare const ApplicativePar: Applicative2<'TaskEither'>

Added in v2.7.0 v2.7.0 中添加

ApplicativeSeq   应用序列

Runs computations sequentially.
按顺序运行计算。

Signature 签名

export declare const ApplicativeSeq: Applicative2<'TaskEither'>

Added in v2.7.0 v2.7.0 中添加

ApplyPar   申请帕

Runs computations in parallel.
并行运行计算。

Signature 签名

export declare const ApplyPar: Apply2<'TaskEither'>

Added in v2.10.0 v2.10.0 中添加

ApplySeq   应用序列

Runs computations sequentially.
按顺序运行计算。

Signature 签名

export declare const ApplySeq: Apply2<'TaskEither'>

Added in v2.10.0 v2.10.0 中添加

Bifunctor   双函子

Signature 签名

export declare const Bifunctor: Bifunctor2<'TaskEither'>

Added in v2.7.0 v2.7.0 中添加

Chain  

Signature 签名

export declare const Chain: chainable.Chain2<'TaskEither'>

Added in v2.10.0 v2.10.0 中添加

FromEither   来自任一

Signature 签名

export declare const FromEither: FromEither2<'TaskEither'>

Added in v2.10.0 v2.10.0 中添加

FromIO   来自IO

Signature 签名

export declare const FromIO: FromIO2<'TaskEither'>

Added in v2.10.0 v2.10.0 中添加

FromTask   来自任务

Signature 签名

export declare const FromTask: FromTask2<'TaskEither'>

Added in v2.10.0 v2.10.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor2<'TaskEither'>

Added in v2.7.0 v2.7.0 中添加

Monad   单子

Signature 签名

export declare const Monad: Monad2<'TaskEither'>

Added in v2.10.0 v2.10.0 中添加

MonadIO   莫纳德奥

Signature 签名

export declare const MonadIO: MonadIO2<'TaskEither'>

Added in v2.10.0 v2.10.0 中添加

MonadTask  单子任务

Signature 签名

export declare const MonadTask: MonadTask2<'TaskEither'>

Added in v2.10.0 v2.10.0 中添加

MonadThrow   单子投掷

Signature 签名

export declare const MonadThrow: MonadThrow2<'TaskEither'>

Added in v2.10.0 v2.10.0 中添加

Pointed  

Signature 签名

export declare const Pointed: Pointed2<'TaskEither'>

Added in v2.10.0 v2.10.0 中添加

interop   互操作

taskify   任务化

Convert a node style callback function to one returning a TaskEither
将节点样式回调函数转换为返回 TaskEither 的回调函数

Note. If the function f admits multiple overloadings, taskify will pick last one. If you want a different behaviour, add an explicit type annotation
笔记。如果函数 f 允许多个重载, taskify 将选择最后一个。如果您想要不同的行为,请添加显式类型注释

// readFile admits multiple overloadings

// const readFile: (a: string) => TaskEither<NodeJS.ErrnoException, Buffer>
const readFile = taskify(fs.readFile)

const readFile2: (filename: string, encoding: string) => TaskEither<NodeJS.ErrnoException, Buffer> = taskify(
  fs.readFile
)

Signature 签名

export declare function taskify<L, R>(f: (cb: (e: L | null | undefined, r?: R) => void) => void): () => TaskEither<L, R>
export declare function taskify<A, L, R>(
  f: (a: A, cb: (e: L | null | undefined, r?: R) => void) => void
): (a: A) => TaskEither<L, R>
export declare function taskify<A, B, L, R>(
  f: (a: A, b: B, cb: (e: L | null | undefined, r?: R) => void) => void
): (a: A, b: B) => TaskEither<L, R>
export declare function taskify<A, B, C, L, R>(
  f: (a: A, b: B, c: C, cb: (e: L | null | undefined, r?: R) => void) => void
): (a: A, b: B, c: C) => TaskEither<L, R>
export declare function taskify<A, B, C, D, L, R>(
  f: (a: A, b: B, c: C, d: D, cb: (e: L | null | undefined, r?: R) => void) => void
): (a: A, b: B, c: C, d: D) => TaskEither<L, R>
export declare function taskify<A, B, C, D, E, L, R>(
  f: (a: A, b: B, c: C, d: D, e: E, cb: (e: L | null | undefined, r?: R) => void) => void
): (a: A, b: B, c: C, d: D, e: E) => TaskEither<L, R>

Example 例子

import { taskify } from 'fp-ts/TaskEither'
import * as fs from 'fs'

// const stat: (a: string | Buffer) => TaskEither<NodeJS.ErrnoException, fs.Stats>
const stat = taskify(fs.stat)
assert.strictEqual(stat.length, 0)

Added in v2.0.0 v2.0.0 中添加

tryCatch   试着抓

Transforms a Promise that may reject to a Promise that never rejects and returns an Either instead.
将可能拒绝的 Promise 转换为从不拒绝的 Promise ,并返回 Either

See also tryCatchK. 另请参阅 tryCatchK

Signature 签名

export declare const tryCatch: <E, A>(f: LazyArg<Promise<A>>, onRejected: (reason: unknown) => E) => TaskEither<E, A>

Example 例子

import { left, right } from 'fp-ts/Either'
import { tryCatch } from 'fp-ts/TaskEither'

tryCatch(() => Promise.resolve(1), String)().then((result) => {
  assert.deepStrictEqual(result, right(1))
})
tryCatch(() => Promise.reject('error'), String)().then((result) => {
  assert.deepStrictEqual(result, left('error'))
})

Added in v2.0.0 v2.0.0 中添加

tryCatchK   尝试捕获K

Converts a function returning a Promise to one returning a TaskEither.
将返回 Promise 的函数转换为返回 TaskEither 的函数。

Signature 签名

export declare const tryCatchK: <E, A extends readonly unknown[], B>(
  f: (...a: A) => Promise<B>,
  onRejected: (reason: unknown) => E
) => (...a: A) => TaskEither<E, B>

Added in v2.5.0 v2.5.0中添加

legacy   遗产

bimap   双图

Alias of mapBoth.  mapBoth 的别名。

Signature 签名

export declare const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: TaskEither<E, A>) => TaskEither<G, B>

Added in v2.0.0 v2.0.0 中添加

chain  

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chain: <E, A, B>(f: (a: A) => TaskEither<E, B>) => (ma: TaskEither<E, A>) => TaskEither<E, B>

Added in v2.0.0 v2.0.0 中添加

chainEitherK  链EiK

Alias of flatMapEither.  flatMapEither 的别名。

Signature 签名

export declare const chainEitherK: <E, A, B>(f: (a: A) => E.Either<E, B>) => (ma: TaskEither<E, A>) => TaskEither<E, B>

Added in v2.4.0 v2.4.0中添加

chainEitherKW  链条任一KW

Alias of flatMapEither.  flatMapEither 的别名。

Signature 签名

export declare const chainEitherKW: <E2, A, B>(
  f: (a: A) => E.Either<E2, B>
) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E2 | E1, B>

Added in v2.6.1 v2.6.1 中添加

chainFirst   链优先

Alias of tap.  tap 的别名。

Signature 签名

export declare const chainFirst: <E, A, B>(f: (a: A) => TaskEither<E, B>) => (ma: TaskEither<E, A>) => TaskEither<E, A>

Added in v2.0.0 v2.0.0 中添加

chainFirstEitherK  链FirstEiK

Alias of tapEither.  tapEither 的别名。

Signature 签名

export declare const chainFirstEitherK: <A, E, B>(
  f: (a: A) => E.Either<E, B>
) => (ma: TaskEither<E, A>) => TaskEither<E, A>

Added in v2.12.0 v2.12.0 中添加

chainFirstEitherKW   链FirstEiKW

Alias of tapEither.  tapEither 的别名。

Less strict version of chainFirstEitherK.
chainFirstEitherK 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const chainFirstEitherKW: <A, E2, B>(
  f: (a: A) => E.Either<E2, B>
) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E2 | E1, A>

Added in v2.12.0 v2.12.0 中添加

chainFirstIOK  链第一IOK

Alias of tapIO.  tapIO 的别名。

Signature 签名

export declare const chainFirstIOK: <A, B>(f: (a: A) => IO<B>) => <E>(first: TaskEither<E, A>) => TaskEither<E, A>

Added in v2.10.0 v2.10.0 中添加

chainFirstTaskK  链第一任务K

Alias of tapTask.  tapTask 的别名。

Signature 签名

export declare const chainFirstTaskK: <A, B>(f: (a: A) => T.Task<B>) => <E>(first: TaskEither<E, A>) => TaskEither<E, A>

Added in v2.10.0 v2.10.0 中添加

chainFirstW  链优先W

Alias of tap.  tap 的别名。

Signature 签名

export declare const chainFirstW: <E2, A, B>(
  f: (a: A) => TaskEither<E2, B>
) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E2 | E1, A>

Added in v2.8.0 v2.8.0 中添加

chainIOEitherK  链IOEitherK

Alias of flatMapIOEither.  flatMapIOEither 的别名。

Signature 签名

export declare const chainIOEitherK: <E, A, B>(
  f: (a: A) => IOEither<E, B>
) => (ma: TaskEither<E, A>) => TaskEither<E, B>

Added in v2.4.0 v2.4.0中添加

chainIOEitherKW   链IOEitherKW

Alias of flatMapIOEither.  flatMapIOEither 的别名。

Less strict version of chainIOEitherK.
chainIOEitherK 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const chainIOEitherKW: <E2, A, B>(
  f: (a: A) => IOEither<E2, B>
) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E2 | E1, B>

Added in v2.6.1 v2.6.1 中添加

chainIOK  链IOK

Alias of flatMapIO.  flatMapIO 的别名。

Signature 签名

export declare const chainIOK: <A, B>(f: (a: A) => IO<B>) => <E>(first: TaskEither<E, A>) => TaskEither<E, B>

Added in v2.10.0 v2.10.0 中添加

chainNullableK   链可空K

Use flatMapNullable. 使用 flatMapNullable

Signature 签名

export declare const chainNullableK: <E>(
  e: E
) => <A, B>(f: (a: A) => B | null | undefined) => (ma: TaskEither<E, A>) => TaskEither<E, NonNullable<B>>

Added in v2.12.0 v2.12.0 中添加

chainOptionK   链选项K

Use flatMapOption. 使用 flatMapOption

Signature 签名

export declare const chainOptionK: <E>(
  onNone: LazyArg<E>
) => <A, B>(f: (a: A) => Option<B>) => (ma: TaskEither<E, A>) => TaskEither<E, B>

Added in v2.10.0 v2.10.0 中添加

chainOptionKW   链条选项KW

Use flatMapOption. 使用 flatMapOption

Signature 签名

export declare const chainOptionKW: <E2>(
  onNone: LazyArg<E2>
) => <A, B>(f: (a: A) => Option<B>) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E2 | E1, B>

Added in v2.13.2 v2.13.2 中添加

chainTaskK  链任务K

Alias of flatMapTask.  flatMapTask 的别名。

Signature 签名

export declare const chainTaskK: <A, B>(f: (a: A) => T.Task<B>) => <E>(first: TaskEither<E, A>) => TaskEither<E, B>

Added in v2.10.0 v2.10.0 中添加

chainTaskOptionK   链任务选项K

Use flatMapTaskOption. 使用 flatMapTaskOption

Signature 签名

export declare const chainTaskOptionK: <E>(
  onNone: LazyArg<E>
) => <A, B>(f: (a: A) => TaskOption<B>) => (ma: TaskEither<E, A>) => TaskEither<E, B>

Added in v2.11.0 v2.11.0 中添加

chainTaskOptionKW   链任务选项KW

Use flatMapTaskOption. 使用 flatMapTaskOption

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const chainTaskOptionKW: <E2>(
  onNone: LazyArg<E2>
) => <A, B>(f: (a: A) => TaskOption<B>) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E2 | E1, B>

Added in v2.12.3 v2.12.3 中添加

chainW   链W

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chainW: <E2, A, B>(
  f: (a: A) => TaskEither<E2, B>
) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E2 | E1, B>

Added in v2.6.0 v2.6.0 中添加

fromNullableK  来自可空K

Use liftNullable. 使用 liftNullable

Signature 签名

export declare const fromNullableK: <E>(
  e: E
) => <A extends readonly unknown[], B>(
  f: (...a: A) => B | null | undefined
) => (...a: A) => TaskEither<E, NonNullable<B>>

Added in v2.12.0 v2.12.0 中添加

fromOptionK   来自选项K

Use liftOption. 使用 liftOption

Signature 签名

export declare const fromOptionK: <E>(
  onNone: LazyArg<E>
) => <A extends readonly unknown[], B>(f: (...a: A) => Option<B>) => (...a: A) => TaskEither<E, B>

Added in v2.10.0 v2.10.0 中添加

mapLeft   地图左

Alias of mapError.  mapError 的别名。

Signature 签名

export declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: TaskEither<E, A>) => TaskEither<G, A>

Added in v2.0.0 v2.0.0 中添加

orElseFirst   或其他优先

Alias of tapError.  tapError 的别名。

Signature 签名

export declare const orElseFirst: <E, B>(
  onLeft: (e: E) => TaskEither<E, B>
) => <A>(ma: TaskEither<E, A>) => TaskEither<E, A>

Added in v2.11.0 v2.11.0 中添加

orElseFirstW   否则先W

Alias of tapError.  tapError 的别名。

Signature 签名

export declare const orElseFirstW: <E1, E2, B>(
  onLeft: (e: E1) => TaskEither<E2, B>
) => <A>(ma: TaskEither<E1, A>) => TaskEither<E1 | E2, A>

Added in v2.11.0 v2.11.0 中添加

lifting   起重

fromEitherK   来自EitherK

Signature 签名

export declare const fromEitherK: <E, A extends readonly unknown[], B>(
  f: (...a: A) => E.Either<E, B>
) => (...a: A) => TaskEither<E, B>

Added in v2.4.0 v2.4.0中添加

fromIOEitherK   来自IOEitherK

Signature 签名

export declare const fromIOEitherK: <E, A extends readonly unknown[], B>(
  f: (...a: A) => IOEither<E, B>
) => (...a: A) => TaskEither<E, B>

Added in v2.4.0 v2.4.0中添加

fromIOK   来自IOK

Signature 签名

export declare const fromIOK: <A extends readonly unknown[], B>(
  f: (...a: A) => IO<B>
) => <E = never>(...a: A) => TaskEither<E, B>

Added in v2.10.0 v2.10.0 中添加

fromPredicate   来自谓词

Signature 签名

export declare const fromPredicate: {
  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => TaskEither<E, B>
  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => TaskEither<E, B>
  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => TaskEither<E, A>
}

Added in v2.0.0 v2.0.0 中添加

fromTaskK   来自任务K

Signature 签名

export declare const fromTaskK: <A extends readonly unknown[], B>(
  f: (...a: A) => T.Task<B>
) => <E = never>(...a: A) => TaskEither<E, B>

Added in v2.10.0 v2.10.0 中添加

fromTaskOptionK   来自任务选项K

Signature 签名

export declare const fromTaskOptionK: <E>(
  onNone: LazyArg<E>
) => <A extends readonly unknown[], B>(f: (...a: A) => TaskOption<B>) => (...a: A) => TaskEither<E, B>

Added in v2.11.0 v2.11.0 中添加

liftNullable   提升可为空

Signature 签名

export declare const liftNullable: <A extends readonly unknown[], B, E>(
  f: (...a: A) => B | null | undefined,
  onNullable: (...a: A) => E
) => (...a: A) => TaskEither<E, NonNullable<B>>

Added in v2.15.0 v2.15.0 中添加

liftOption   电梯选项

Signature 签名

export declare const liftOption: <A extends readonly unknown[], B, E>(
  f: (...a: A) => Option<B>,
  onNone: (...a: A) => E
) => (...a: A) => TaskEither<E, B>

Added in v2.15.0 v2.15.0 中添加

mapping   映射

as   作为

Maps the Right value of this TaskEither to the specified constant value.
将此 TaskEitherRight 值映射到指定的常量值。

Signature 签名

export declare const as: {
  <A>(a: A): <E, _>(self: TaskEither<E, _>) => TaskEither<E, A>
  <E, _, A>(self: TaskEither<E, _>, a: A): TaskEither<E, A>
}

Added in v2.16.0 v2.16.0 中添加

asUnit   作为单位

Maps the Right value of this TaskEither to the void constant value.
将此 TaskEitherRight 值映射到void 常量值。

Signature 签名

export declare const asUnit: <E, _>(self: TaskEither<E, _>) => TaskEither<E, void>

Added in v2.16.0 v2.16.0 中添加

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <E, B>(fab: TaskEither<E, (a: A) => B>) => TaskEither<E, B>

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => <E>(fa: TaskEither<E, A>) => TaskEither<E, B>

Added in v2.0.0 v2.0.0 中添加

model   模型

TaskEither (interface)   任务要么(接口)

Signature 签名

export interface TaskEither<E, A> extends Task<Either<E, A>> {}

Added in v2.0.0 v2.0.0 中添加

pattern matching   模式匹配

fold   折叠

Alias of matchE.  matchE 的别名。

Signature 签名

export declare const fold: <E, A, B>(
  onLeft: (e: E) => T.Task<B>,
  onRight: (a: A) => T.Task<B>
) => (ma: TaskEither<E, A>) => T.Task<B>

Added in v2.0.0 v2.0.0 中添加

foldW   折叠W

Alias of matchEW.  matchEW 的别名。

Signature 签名

export declare const foldW: <E, B, A, C>(
  onLeft: (e: E) => T.Task<B>,
  onRight: (a: A) => T.Task<C>
) => (ma: TaskEither<E, A>) => T.Task<B | C>

Added in v2.10.0 v2.10.0 中添加

match   匹配

Signature 签名

export declare const match: <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: TaskEither<E, A>) => T.Task<B>

Added in v2.10.0 v2.10.0 中添加

matchE   匹配E

The E suffix (short for Effect) means that the handlers return an effect (Task).
E 后缀(Effect 的缩写)意味着处理程序返回一个效果 ( Task )。

Signature 签名

export declare const matchE: <E, A, B>(
  onLeft: (e: E) => T.Task<B>,
  onRight: (a: A) => T.Task<B>
) => (ma: TaskEither<E, A>) => T.Task<B>

Added in v2.10.0 v2.10.0 中添加

matchEW   匹配电子战

Less strict version of matchE.
matchE 的不太严格版本。

The W suffix (short for Widening) means that the handler return types will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const matchEW: <E, B, A, C>(
  onLeft: (e: E) => T.Task<B>,
  onRight: (a: A) => T.Task<C>
) => (ma: TaskEither<E, A>) => T.Task<B | C>

Added in v2.10.0 v2.10.0 中添加

matchW   匹配W

Less strict version of match.
match 的不太严格版本。

The W suffix (short for Widening) means that the handler return types will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const matchW: <E, B, A, C>(
  onLeft: (e: E) => B,
  onRight: (a: A) => C
) => (ma: TaskEither<E, A>) => T.Task<B | C>

Added in v2.10.0 v2.10.0 中添加

sequencing   测序

flatMap   平面地图

Signature 签名

export declare const flatMap: {
  <A, E2, B>(f: (a: A) => TaskEither<E2, B>): <E1>(ma: TaskEither<E1, A>) => TaskEither<E2 | E1, B>
  <E1, A, E2, B>(ma: TaskEither<E1, A>, f: (a: A) => TaskEither<E2, B>): TaskEither<E1 | E2, B>
}

Added in v2.14.0 v2.14.0 中添加

flatMapEither   平面地图要么

Signature 签名

export declare const flatMapEither: {
  <A, E2, B>(f: (a: A) => E.Either<E2, B>): <E1>(self: TaskEither<E1, A>) => TaskEither<E2 | E1, B>
  <E1, A, E2, B>(self: TaskEither<E1, A>, f: (a: A) => E.Either<E2, B>): TaskEither<E1 | E2, B>
}

Added in v2.15.0 v2.15.0 中添加

flatMapIO   平面MapIO

Signature 签名

export declare const flatMapIO: {
  <A, B>(f: (a: A) => IO<B>): <E>(self: TaskEither<E, A>) => TaskEither<E, B>
  <E, A, B>(self: TaskEither<E, A>, f: (a: A) => IO<B>): TaskEither<E, B>
}

Added in v2.15.0 v2.15.0 中添加

flatMapIOEither   平面MapIO要么

Signature 签名

export declare const flatMapIOEither: {
  <A, E2, B>(f: (a: A) => IOEither<E2, B>): <E1>(self: TaskEither<E1, A>) => TaskEither<E2 | E1, B>
  <E1, A, E2, B>(self: TaskEither<E1, A>, f: (a: A) => IOEither<E2, B>): TaskEither<E1 | E2, B>
}

Added in v2.16.0 v2.16.0 中添加

flatMapNullable   平面地图可空

Signature 签名

export declare const flatMapNullable: {
  <A, B, E2>(f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): <E1>(
    self: TaskEither<E1, A>
  ) => TaskEither<E2 | E1, NonNullable<B>>
  <E1, A, B, E2>(self: TaskEither<E1, A>, f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): TaskEither<
    E1 | E2,
    NonNullable<B>
  >
}

Added in v2.15.0 v2.15.0 中添加

flatMapOption   平面地图选项

Signature 签名

export declare const flatMapOption: {
  <A, B, E2>(f: (a: A) => Option<B>, onNone: (a: A) => E2): <E1>(self: TaskEither<E1, A>) => TaskEither<E2 | E1, B>
  <E1, A, B, E2>(self: TaskEither<E1, A>, f: (a: A) => Option<B>, onNone: (a: A) => E2): TaskEither<E1 | E2, B>
}

Added in v2.15.0 v2.15.0 中添加

flatMapTask  平面地图任务

Signature 签名

export declare const flatMapTask: {
  <A, B>(f: (a: A) => T.Task<B>): <E>(self: TaskEither<E, A>) => TaskEither<E, B>
  <E, A, B>(self: TaskEither<E, A>, f: (a: A) => T.Task<B>): TaskEither<E, B>
}

Added in v2.16.0 v2.16.0 中添加

flatMapTaskOption   平面地图任务选项

Signature 签名

export declare const flatMapTaskOption: {
  <A, E2, B>(f: (a: A) => TaskOption<B>, onNone: (a: A) => E2): <E1>(self: TaskEither<E1, A>) => TaskEither<E2 | E1, B>
  <E1, A, E2, B>(self: TaskEither<E1, A>, f: (a: A) => TaskOption<B>, onNone: (a: A) => E2): TaskEither<E1 | E2, B>
}

Added in v2.16.0 v2.16.0 中添加

flatten   压扁

Signature 签名

export declare const flatten: <E, A>(mma: TaskEither<E, TaskEither<E, A>>) => TaskEither<E, A>

Added in v2.0.0 v2.0.0 中添加

flattenW   展平W

Less strict version of flatten.
flatten 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const flattenW: <E1, E2, A>(mma: TaskEither<E1, TaskEither<E2, A>>) => TaskEither<E1 | E2, A>

Added in v2.11.0 v2.11.0 中添加

traversing   穿越

sequenceArray   序列数组

Equivalent to ReadonlyArray#sequence(Applicative). 相当于 ReadonlyArray#sequence(Applicative)

Signature 签名

export declare const sequenceArray: <A, E>(arr: readonly TaskEither<E, A>[]) => TaskEither<E, readonly A[]>

Added in v2.9.0 v2.9.0中添加

sequenceSeqArray   序列SeqArray

Equivalent to ReadonlyArray#sequence(ApplicativeSeq). 相当于 ReadonlyArray#sequence(ApplicativeSeq)

Signature 签名

export declare const sequenceSeqArray: <A, E>(arr: readonly TaskEither<E, A>[]) => TaskEither<E, readonly A[]>

Added in v2.9.0 v2.9.0中添加

traverseArray   遍历数组

Equivalent to ReadonlyArray#traverse(Applicative). 相当于 ReadonlyArray#traverse(Applicative)

Signature 签名

export declare const traverseArray: <A, B, E>(
  f: (a: A) => TaskEither<E, B>
) => (as: readonly A[]) => TaskEither<E, readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseArrayWithIndex   带索引遍历数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseArrayWithIndex: <A, B, E>(
  f: (index: number, a: A) => TaskEither<E, B>
) => (as: readonly A[]) => TaskEither<E, readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseReadonlyArrayWithIndex
遍历带索引的只读数组

Equivalent to ReadonlyArray#traverseWithIndex(ApplicativePar). 相当于 ReadonlyArray#traverseWithIndex(ApplicativePar)

Signature 签名

export declare const traverseReadonlyArrayWithIndex: <A, E, B>(
  f: (index: number, a: A) => TaskEither<E, B>
) => (as: readonly A[]) => TaskEither<E, readonly B[]>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyArrayWithIndexSeq
遍历ReadonlyArrayWithIndexSeq

Equivalent to ReadonlyArray#traverseWithIndex(ApplicativeSeq). 相当于 ReadonlyArray#traverseWithIndex(ApplicativeSeq)

Signature 签名

export declare const traverseReadonlyArrayWithIndexSeq: <A, E, B>(
  f: (index: number, a: A) => TaskEither<E, B>
) => (as: readonly A[]) => TaskEither<E, readonly B[]>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyNonEmptyArrayWithIndex
遍历ReadonlyNonEmptyArrayWithIndex

Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar). 相当于 ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar)

Signature 签名

export declare const traverseReadonlyNonEmptyArrayWithIndex: <A, E, B>(
  f: (index: number, a: A) => TaskEither<E, B>
) => (as: ReadonlyNonEmptyArray<A>) => TaskEither<E, ReadonlyNonEmptyArray<B>>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyNonEmptyArrayWithIndexSeq
遍历ReadonlyNonEmptyArrayWithIndexSeq

Equivalent to ReadonlyArray#traverseWithIndex(ApplicativeSeq). 相当于 ReadonlyArray#traverseWithIndex(ApplicativeSeq)

Signature 签名

export declare const traverseReadonlyNonEmptyArrayWithIndexSeq: <A, E, B>(
  f: (index: number, a: A) => TaskEither<E, B>
) => (as: ReadonlyNonEmptyArray<A>) => TaskEither<E, ReadonlyNonEmptyArray<B>>

Added in v2.11.0 v2.11.0 中添加

traverseSeqArray   遍历SeqArray

Equivalent to ReadonlyArray#traverse(ApplicativeSeq). 相当于 ReadonlyArray#traverse(ApplicativeSeq)

Signature 签名

export declare const traverseSeqArray: <A, B, E>(
  f: (a: A) => TaskEither<E, B>
) => (as: readonly A[]) => TaskEither<E, readonly B[]>

Added in v2.9.0 v2.9.0中添加

traverseSeqArrayWithIndex
带索引的遍历SeqArray

Equivalent to ReadonlyArray#traverseWithIndex(ApplicativeSeq). 相当于 ReadonlyArray#traverseWithIndex(ApplicativeSeq)

Signature 签名

export declare const traverseSeqArrayWithIndex: <A, B, E>(
  f: (index: number, a: A) => TaskEither<E, B>
) => (as: readonly A[]) => TaskEither<E, readonly B[]>

Added in v2.9.0 v2.9.0中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'TaskEither'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

ApT   易于

Signature 签名

export declare const ApT: TaskEither<never, readonly []>

Added in v2.11.0 v2.11.0 中添加

ap   美联社

Signature 签名

export declare const ap: <E, A>(fa: TaskEither<E, A>) => <B>(fab: TaskEither<E, (a: A) => B>) => TaskEither<E, B>

Added in v2.0.0 v2.0.0 中添加

apFirst   应用程序第一

Combine two effectful actions, keeping only the result of the first.
结合两个有效的操作,仅保留第一个操作的结果。

Signature 签名

export declare const apFirst: <E, B>(second: TaskEither<E, B>) => <A>(first: TaskEither<E, A>) => TaskEither<E, A>

Added in v2.0.0 v2.0.0 中添加

apFirstW   apFirstW

Less strict version of apFirst.
apFirst 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const apFirstW: <E2, B>(
  second: TaskEither<E2, B>
) => <E1, A>(first: TaskEither<E1, A>) => TaskEither<E2 | E1, A>

Added in v2.12.0 v2.12.0 中添加

apSecond   ap秒

Combine two effectful actions, keeping only the result of the second.
结合两个有效的操作,只保留第二个的结果。

Signature 签名

export declare const apSecond: <E, B>(second: TaskEither<E, B>) => <A>(first: TaskEither<E, A>) => TaskEither<E, B>

Added in v2.0.0 v2.0.0 中添加

apSecondW   apSecondW

Less strict version of apSecond.
apSecond 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const apSecondW: <E2, B>(
  second: TaskEither<E2, B>
) => <E1, A>(first: TaskEither<E1, A>) => TaskEither<E2 | E1, B>

Added in v2.12.0 v2.12.0 中添加

apW   平均功率

Less strict version of ap.
ap 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const apW: <E2, A>(
  fa: TaskEither<E2, A>
) => <E1, B>(fab: TaskEither<E1, (a: A) => B>) => TaskEither<E2 | E1, B>

Added in v2.8.0 v2.8.0 中添加

bracket   括号

Make sure that a resource is cleaned up in the event of an exception (*). The release action is called regardless of whether the body action throws (*) or returns.
确保在发生异常时清理资源 (*)。无论主体操作是抛出 (*) 还是返回,都会调用释放操作。

(*) i.e. returns a Left
(*) 即返回 Left

Signature 签名

export declare const bracket: <E, A, B>(
  acquire: TaskEither<E, A>,
  use: (a: A) => TaskEither<E, B>,
  release: (a: A, e: E.Either<E, B>) => TaskEither<E, void>
) => TaskEither<E, B>

Added in v2.0.0 v2.0.0 中添加

bracketW   支架W

Less strict version of bracket.
bracket 的不太严格版本。

The W suffix (short for Widening) means that the error types will be merged.
W 后缀(Widening 的缩写)意味着错误类型将被合并。

Signature 签名

export declare const bracketW: <E1, A, E2, B, E3>(
  acquire: TaskEither<E1, A>,
  use: (a: A) => TaskEither<E2, B>,
  release: (a: A, e: E.Either<E2, B>) => TaskEither<E3, void>
) => TaskEither<E1 | E2 | E3, B>

Added in v2.12.0 v2.12.0 中添加

swap   交换

Signature 签名

export declare const swap: <E, A>(ma: TaskEither<E, A>) => TaskEither<A, E>

Added in v2.0.0 v2.0.0 中添加

throwError   抛出错误

Signature 签名

export declare const throwError: <E, A>(e: E) => TaskEither<E, A>

Added in v2.7.0 v2.7.0 中添加

zone of death
死亡地带

getApplyMonoid 获取应用Monoid

Use getApplicativeMonoid instead. 请改用 getApplicativeMonoid

Signature 签名

export declare const getApplyMonoid: <E, A>(M: Monoid<A>) => Monoid<TaskEither<E, A>>

Added in v2.0.0 v2.0.0 中添加

getApplySemigroup 获取ApplySemigroup

Use getApplySemigroup instead. 请改用 getApplySemigroup

Signature 签名

export declare const getApplySemigroup: <E, A>(S: Semigroup<A>) => Semigroup<TaskEither<E, A>>

Added in v2.0.0 v2.0.0 中添加

getSemigroup 获取半群

Use getApplySemigroup instead. 请改用 getApplySemigroup

Signature 签名

export declare const getSemigroup: <E, A>(S: Semigroup<A>) => Semigroup<TaskEither<E, A>>

Added in v2.0.0 v2.0.0 中添加

getTaskValidation 获取任务验证

Use getApplicativeTaskValidation and getAltTaskValidation instead.
请改用 getApplicativeTaskValidationgetAltTaskValidation

Signature 签名

export declare function getTaskValidation<E>(
  SE: Semigroup<E>
): Monad2C<URI, E> & Bifunctor2<URI> & Alt2C<URI, E> & MonadTask2C<URI, E> & MonadThrow2C<URI, E>

Added in v2.0.0 v2.0.0 中添加

taskEitherSeq 任务任一序列

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass TE.Functor instead of TE.taskEitherSeq (where TE is from import TE from 'fp-ts/TaskEither')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 TE.Functor 而不是 TE.taskEitherSeq (其中 TE 来自 import TE from 'fp-ts/TaskEither'

Signature 签名

export declare const taskEitherSeq: Monad2<'TaskEither'> &
  Bifunctor2<'TaskEither'> &
  Alt2<'TaskEither'> &
  MonadTask2<'TaskEither'> &
  MonadThrow2<'TaskEither'>

Added in v2.0.0 v2.0.0 中添加

taskEither 任务要么

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass TE.Functor instead of TE.taskEither (where TE is from import TE from 'fp-ts/TaskEither')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 TE.Functor 而不是 TE.taskEither (其中 TE 来自 import TE from 'fp-ts/TaskEither'

Signature 签名

export declare const taskEither: Monad2<'TaskEither'> &
  Bifunctor2<'TaskEither'> &
  Alt2<'TaskEither'> &
  MonadTask2<'TaskEither'> &
  MonadThrow2<'TaskEither'>

Added in v2.0.0 v2.0.0 中添加

TaskOption overview  任务选项概述

Added in v2.10.0 v2.10.0 中添加


Table of contents
目录


combinators   组合器

tap   轻敲

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tap: {
  <A, _>(self: TaskOption<A>, f: (a: A) => TaskOption<_>): TaskOption<A>
  <A, _>(f: (a: A) => TaskOption<_>): (self: TaskOption<A>) => TaskOption<A>
}

Added in v2.15.0 v2.15.0 中添加

tapEither   点击任一

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapEither: {
  <A, E, _>(f: (a: A) => Either<E, _>): (self: TaskOption<A>) => TaskOption<A>
  <A, E, _>(self: TaskOption<A>, f: (a: A) => Either<E, _>): TaskOption<A>
}

Example 例子

import { pipe } from 'fp-ts/function'
import * as TO from 'fp-ts/TaskOption'
import * as O from 'fp-ts/Option'
import * as E from 'fp-ts/Either'

const compute = (value: number) =>
  pipe(
    TO.of(value),
    TO.tapEither((value) => (value > 0 ? E.right('ok') : E.left('error')))
  )

async function test() {
  assert.deepStrictEqual(await compute(1)(), O.of(1))
  assert.deepStrictEqual(await compute(-1)(), O.none)
}

test()

Added in v2.16.0 v2.16.0 中添加

tapIO   tapIO

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapIO: {
  <A, _>(f: (a: A) => IO<_>): (self: TaskOption<A>) => TaskOption<A>
  <A, _>(self: TaskOption<A>, f: (a: A) => IO<_>): TaskOption<A>
}

Example 例子

import { pipe } from 'fp-ts/function'
import * as TO from 'fp-ts/TaskOption'
import * as O from 'fp-ts/Option'
import * as Console from 'fp-ts/Console'

// Will produce `Hello, fp-ts` to the stdout
const effectA = TO.tapIO(TO.of(1), (value) => Console.log(`Hello, ${value}`))

// No output to the stdout
const effectB = pipe(
  TO.none as TO.TaskOption<string>,
  TO.tapIO((value) => Console.log(`Hello, ${value}`))
)

async function test() {
  assert.deepStrictEqual(await effectA(), O.of(1))
  assert.deepStrictEqual(await effectB(), O.none)
}

test()

Added in v2.16.0 v2.16.0 中添加

tapTask   点击任务

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const tapTask: {
  <A, _>(f: (a: A) => T.Task<_>): (self: TaskOption<A>) => TaskOption<A>
  <A, _>(self: TaskOption<A>, f: (a: A) => T.Task<_>): TaskOption<A>
}

Example 例子

import * as TO from 'fp-ts/TaskOption'
import * as O from 'fp-ts/Option'
import * as T from 'fp-ts/Task'

const effect = TO.tapIO(TO.of(1), (value) => T.of(value + 1))

async function test() {
  assert.deepStrictEqual(await effect(), O.of(1))
}

test()

Added in v2.16.0 v2.16.0 中添加

constructors  构造函数

none   没有任何

Signature 签名

export declare const none: TaskOption<never>

Added in v2.10.0 v2.10.0 中添加

of  

Signature 签名

export declare const of: <A>(a: A) => TaskOption<A>

Added in v2.10.0 v2.10.0 中添加

some   一些

Signature 签名

export declare const some: <A>(a: A) => TaskOption<A>

Added in v2.10.0 v2.10.0 中添加

conversions   转换

fromEither   来自任一

Signature 签名

export declare const fromEither: <A>(fa: Either<unknown, A>) => TaskOption<A>

Added in v2.10.0 v2.10.0 中添加

fromIO   来自IO

Signature 签名

export declare const fromIO: <A>(fa: IO<A>) => TaskOption<A>

Added in v2.10.0 v2.10.0 中添加

fromNullable   来自可为空的

Signature 签名

export declare const fromNullable: <A>(a: A) => TaskOption<NonNullable<A>>

Added in v2.10.0 v2.10.0 中添加

fromOption   来自选项

Signature 签名

export declare const fromOption: <A>(fa: O.Option<A>) => TaskOption<A>

Added in v2.10.0 v2.10.0 中添加

fromTask   来自任务

Signature 签名

export declare const fromTask: <A>(fa: T.Task<A>) => TaskOption<A>

Added in v2.10.0 v2.10.0 中添加

fromTaskEither   来自任务要么

Signature 签名

export declare const fromTaskEither: <A>(fa: TaskEither<unknown, A>) => TaskOption<A>

Added in v2.11.0 v2.11.0 中添加

do notation   做记号

Do  

Signature 签名

export declare const Do: TaskOption<{}>

Added in v2.10.0 v2.10.0 中添加

apS   apS

Signature 签名

export declare const apS: <N, A, B>(
  name: Exclude<N, keyof A>,
  fb: TaskOption<B>
) => (fa: TaskOption<A>) => TaskOption<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.10.0 v2.10.0 中添加

bind   绑定

Signature 签名

export declare const bind: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => TaskOption<B>
) => (ma: TaskOption<A>) => TaskOption<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.10.0 v2.10.0 中添加

bindTo   绑定到

Signature 签名

export declare const bindTo: <N>(name: N) => <A>(fa: TaskOption<A>) => TaskOption<{ readonly [K in N]: A }>

Added in v2.10.0 v2.10.0 中添加

guard   警卫

Signature 签名

export declare const guard: (b: boolean) => TaskOption<void>

Added in v2.11.0 v2.11.0 中添加

let  

Signature 签名

export declare const let: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => (fa: TaskOption<A>) => TaskOption<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.13.0 v2.13.0 中添加

error handling   错误处理

alt   替代

Signature 签名

export declare const alt: <A>(second: LazyArg<TaskOption<A>>) => (first: TaskOption<A>) => TaskOption<A>

Added in v2.10.0 v2.10.0 中添加

altW   替代W

Less strict version of alt.
alt 的不太严格版本。

The W suffix (short for Widening) means that the return types will be merged.
W 后缀(Widening 的缩写)意味着返回类型将被合并。

Signature 签名

export declare const altW: <B>(second: LazyArg<TaskOption<B>>) => <A>(first: TaskOption<A>) => TaskOption<B | A>

Added in v2.10.0 v2.10.0 中添加

getOrElse  获取或否则

Signature 签名

export declare const getOrElse: <A>(onNone: LazyArg<T.Task<A>>) => (fa: TaskOption<A>) => T.Task<A>

Added in v2.10.0 v2.10.0 中添加

getOrElseW   获取或否则W

Less strict version of getOrElse.
getOrElse 的不太严格版本。

The W suffix (short for Widening) means that the handler return type will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const getOrElseW: <B>(onNone: LazyArg<T.Task<B>>) => <A>(ma: TaskOption<A>) => T.Task<B | A>

Added in v2.10.0 v2.10.0 中添加

filtering   过滤

compact   袖珍的

Signature 签名

export declare const compact: <A>(fa: TaskOption<O.Option<A>>) => TaskOption<A>

Added in v2.10.0 v2.10.0 中添加

filter   筛选

Signature 签名

export declare const filter: {
  <A, B extends A>(refinement: Refinement<A, B>): (fb: TaskOption<A>) => TaskOption<B>
  <A>(predicate: Predicate<A>): <B extends A>(fb: TaskOption<B>) => TaskOption<B>
  <A>(predicate: Predicate<A>): (fa: TaskOption<A>) => TaskOption<A>
}

Added in v2.10.0 v2.10.0 中添加

filterMap   过滤映射

Signature 签名

export declare const filterMap: <A, B>(f: (a: A) => O.Option<B>) => (fga: TaskOption<A>) => TaskOption<B>

Added in v2.10.0 v2.10.0 中添加

partition   分割

Signature 签名

export declare const partition: {
  <A, B extends A>(refinement: Refinement<A, B>): (fb: TaskOption<A>) => Separated<TaskOption<A>, TaskOption<B>>
  <A>(predicate: Predicate<A>): <B extends A>(fb: TaskOption<B>) => Separated<TaskOption<B>, TaskOption<B>>
  <A>(predicate: Predicate<A>): (fa: TaskOption<A>) => Separated<TaskOption<A>, TaskOption<A>>
}

Added in v2.10.0 v2.10.0 中添加

partitionMap   分区图

Signature 签名

export declare const partitionMap: <A, B, C>(
  f: (a: A) => Either<B, C>
) => (fa: TaskOption<A>) => Separated<TaskOption<B>, TaskOption<C>>

Added in v2.10.0 v2.10.0 中添加

separate   分离

Signature 签名

export declare const separate: <A, B>(fa: TaskOption<Either<A, B>>) => Separated<TaskOption<A>, TaskOption<B>>

Added in v2.10.0 v2.10.0 中添加

instances   实例

Alt   替代

Signature 签名

export declare const Alt: Alt1<'TaskOption'>

Added in v2.10.0 v2.10.0 中添加

Alternative   选择

Signature 签名

export declare const Alternative: Alternative1<'TaskOption'>

Added in v2.10.0 v2.10.0 中添加

ApplicativePar   应用性参数

Runs computations in parallel.
并行运行计算。

Signature 签名

export declare const ApplicativePar: Applicative1<'TaskOption'>

Added in v2.10.0 v2.10.0 中添加

ApplicativeSeq   应用序列

Runs computations sequentially.
按顺序运行计算。

Signature 签名

export declare const ApplicativeSeq: Applicative1<'TaskOption'>

Added in v2.10.0 v2.10.0 中添加

ApplyPar   申请帕

Runs computations in parallel.
并行运行计算。

Signature 签名

export declare const ApplyPar: Apply1<'TaskOption'>

Added in v2.10.0 v2.10.0 中添加

ApplySeq   应用序列

Runs computations sequentially.
按顺序运行计算。

Signature 签名

export declare const ApplySeq: Apply1<'TaskOption'>

Added in v2.10.0 v2.10.0 中添加

Chain  

Signature 签名

export declare const Chain: chainable.Chain1<'TaskOption'>

Added in v2.10.0 v2.10.0 中添加

Compactable   紧凑型

Signature 签名

export declare const Compactable: Compactable1<'TaskOption'>

Added in v2.10.0 v2.10.0 中添加

Filterable   可过滤

Signature 签名

export declare const Filterable: Filterable1<'TaskOption'>

Added in v2.10.0 v2.10.0 中添加

FromEither   来自任一

Signature 签名

export declare const FromEither: FromEither1<'TaskOption'>

Added in v2.11.0 v2.11.0 中添加

FromIO   来自IO

Signature 签名

export declare const FromIO: FromIO1<'TaskOption'>

Added in v2.10.0 v2.10.0 中添加

FromTask   来自任务

Signature 签名

export declare const FromTask: FromTask1<'TaskOption'>

Added in v2.10.0 v2.10.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor1<'TaskOption'>

Added in v2.10.0 v2.10.0 中添加

Monad   单子

Signature 签名

export declare const Monad: Monad1<'TaskOption'>

Added in v2.10.0 v2.10.0 中添加

MonadIO   莫纳德奥

Signature 签名

export declare const MonadIO: MonadIO1<'TaskOption'>

Added in v2.10.0 v2.10.0 中添加

MonadTask  单子任务

Signature 签名

export declare const MonadTask: MonadTask1<'TaskOption'>

Added in v2.10.0 v2.10.0 中添加

Pointed  

Signature 签名

export declare const Pointed: Pointed1<'TaskOption'>

Added in v2.10.0 v2.10.0 中添加

Zero  

Signature 签名

export declare const Zero: Zero1<'TaskOption'>

Added in v2.11.0 v2.11.0 中添加

interop   互操作

tryCatch   试着抓

Transforms a Promise that may reject to a Promise that never rejects and returns an Option instead.
将可能拒绝的 Promise 转换为从不拒绝的 Promise ,并返回 Option

See also tryCatchK. 另请参阅 tryCatchK

Signature 签名

export declare const tryCatch: <A>(f: LazyArg<Promise<A>>) => TaskOption<A>

Added in v2.10.0 v2.10.0 中添加

tryCatchK   尝试捕获K

Converts a function returning a Promise to one returning a TaskOption.
将返回 Promise 的函数转换为返回 TaskOption 的函数。

Signature 签名

export declare const tryCatchK: <A extends readonly unknown[], B>(
  f: (...a: A) => Promise<B>
) => (...a: A) => TaskOption<B>

Added in v2.10.0 v2.10.0 中添加

legacy   遗产

chain  

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chain: <A, B>(f: (a: A) => TaskOption<B>) => (ma: TaskOption<A>) => TaskOption<B>

Added in v2.10.0 v2.10.0 中添加

chainFirst   链优先

Alias of tap.  tap 的别名。

Signature 签名

export declare const chainFirst: <A, B>(f: (a: A) => TaskOption<B>) => (first: TaskOption<A>) => TaskOption<A>

Added in v2.10.0 v2.10.0 中添加

chainFirstEitherK  链FirstEiK

Alias of tapEither.  tapEither 的别名。

Signature 签名

export declare const chainFirstEitherK: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: TaskOption<A>) => TaskOption<A>

Added in v2.12.0 v2.12.0 中添加

chainFirstIOK  链第一IOK

Alias of tapIO.  tapIO 的别名。

Signature 签名

export declare const chainFirstIOK: <A, B>(f: (a: A) => IO<B>) => (first: TaskOption<A>) => TaskOption<A>

Added in v2.10.0 v2.10.0 中添加

chainFirstTaskK  链第一任务K

Alias of tapTask.  tapTask 的别名。

Signature 签名

export declare const chainFirstTaskK: <A, B>(f: (a: A) => T.Task<B>) => (first: TaskOption<A>) => TaskOption<A>

Added in v2.10.0 v2.10.0 中添加

chainIOK  链IOK

Alias of flatMapIO.  flatMapIO 的别名。

Signature 签名

export declare const chainIOK: <A, B>(f: (a: A) => IO<B>) => (first: TaskOption<A>) => TaskOption<B>

Added in v2.10.0 v2.10.0 中添加

chainTaskK  链任务K

Alias of flatMapTask.  flatMapTask 的别名。

Signature 签名

export declare const chainTaskK: <A, B>(f: (a: A) => T.Task<B>) => (first: TaskOption<A>) => TaskOption<B>

Added in v2.10.0 v2.10.0 中添加

lifting   起重

fromEitherK   来自EitherK

Signature 签名

export declare const fromEitherK: <E, A extends readonly unknown[], B>(
  f: (...a: A) => Either<E, B>
) => (...a: A) => TaskOption<B>

Added in v2.12.0 v2.12.0 中添加

fromIOK   来自IOK

Signature 签名

export declare const fromIOK: <A extends readonly unknown[], B>(f: (...a: A) => IO<B>) => (...a: A) => TaskOption<B>

Added in v2.10.0 v2.10.0 中添加

fromNullableK  来自可空K

Signature 签名

export declare const fromNullableK: <A extends readonly unknown[], B>(
  f: (...a: A) => B | null | undefined
) => (...a: A) => TaskOption<NonNullable<B>>

Added in v2.10.0 v2.10.0 中添加

fromOptionK   来自选项K

Signature 签名

export declare const fromOptionK: <A extends readonly unknown[], B>(
  f: (...a: A) => O.Option<B>
) => (...a: A) => TaskOption<B>

Added in v2.10.0 v2.10.0 中添加

fromPredicate   来自谓词

Signature 签名

export declare const fromPredicate: {
  <A, B extends A>(refinement: Refinement<A, B>): (a: A) => TaskOption<B>
  <A>(predicate: Predicate<A>): <B extends A>(b: B) => TaskOption<B>
  <A>(predicate: Predicate<A>): (a: A) => TaskOption<A>
}

Added in v2.10.0 v2.10.0 中添加

fromTaskK   来自任务K

Signature 签名

export declare const fromTaskK: <A extends readonly unknown[], B>(
  f: (...a: A) => T.Task<B>
) => (...a: A) => TaskOption<B>

Added in v2.10.0 v2.10.0 中添加

mapping   映射

as   作为

Maps the Some value of this TaskOption to the specified constant value.
将此 TaskOptionSome 值映射到指定的常量值。

Signature 签名

export declare const as: {
  <A>(a: A): <_>(self: TaskOption<_>) => TaskOption<A>
  <_, A>(self: TaskOption<_>, a: A): TaskOption<A>
}

Added in v2.16.0 v2.16.0 中添加

asUnit   作为单位

Maps the Some value of this TaskOption to the void constant value.
将此 TaskOptionSome 值映射到void 常量值。

Signature 签名

export declare const asUnit: <_>(self: TaskOption<_>) => TaskOption<void>

Added in v2.16.0 v2.16.0 中添加

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <B>(fab: TaskOption<(a: A) => B>) => TaskOption<B>

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => (fa: TaskOption<A>) => TaskOption<B>

Added in v2.10.0 v2.10.0 中添加

model   模型

TaskOption (interface)   任务选项(接口)

Signature 签名

export interface TaskOption<A> extends Task<Option<A>> {}

Added in v2.10.0 v2.10.0 中添加

pattern matching   模式匹配

fold   折叠

Alias of matchE.  matchE 的别名。

Signature 签名

export declare const fold: <B, A>(
  onNone: () => T.Task<B>,
  onSome: (a: A) => T.Task<B>
) => (ma: TaskOption<A>) => T.Task<B>

Added in v2.10.0 v2.10.0 中添加

foldW   折叠W

Alias of matchEW.  matchEW 的别名。

Signature 签名

export declare const foldW: <B, C, A>(
  onNone: () => T.Task<B>,
  onSome: (a: A) => T.Task<C>
) => (ma: TaskOption<A>) => T.Task<B | C>

Added in v2.10.0 v2.10.0 中添加

match   匹配

Signature 签名

export declare const match: <B, A>(onNone: () => B, onSome: (a: A) => B) => (ma: TaskOption<A>) => T.Task<B>

Added in v2.10.0 v2.10.0 中添加

matchE   匹配E

The E suffix (short for Effect) means that the handlers return an effect (Task).
E 后缀(Effect 的缩写)意味着处理程序返回一个效果 ( Task )。

Signature 签名

export declare const matchE: <B, A>(
  onNone: () => T.Task<B>,
  onSome: (a: A) => T.Task<B>
) => (ma: TaskOption<A>) => T.Task<B>

Added in v2.10.0 v2.10.0 中添加

matchEW   匹配电子战

Less strict version of matchE.
matchE 的不太严格版本。

The W suffix (short for Widening) means that the handler return types will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const matchEW: <B, C, A>(
  onNone: () => T.Task<B>,
  onSome: (a: A) => T.Task<C>
) => (ma: TaskOption<A>) => T.Task<B | C>

Added in v2.10.0 v2.10.0 中添加

matchW   匹配W

Less strict version of match.
match 的不太严格版本。

The W suffix (short for Widening) means that the handler return types will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const matchW: <B, A, C>(onNone: () => B, onSome: (a: A) => C) => (ma: TaskOption<A>) => T.Task<B | C>

Added in v2.10.0 v2.10.0 中添加

sequencing   测序

chainEitherK  链EiK

Signature 签名

export declare const chainEitherK: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: TaskOption<A>) => TaskOption<B>

Added in v2.12.0 v2.12.0 中添加

chainNullableK   链可空K

Signature 签名

export declare const chainNullableK: <A, B>(
  f: (a: A) => B | null | undefined
) => (ma: TaskOption<A>) => TaskOption<NonNullable<B>>

Added in v2.10.0 v2.10.0 中添加

chainOptionK   链选项K

Signature 签名

export declare const chainOptionK: <A, B>(f: (a: A) => O.Option<B>) => (ma: TaskOption<A>) => TaskOption<B>

Added in v2.10.0 v2.10.0 中添加

flatMap   平面地图

Signature 签名

export declare const flatMap: {
  <A, B>(f: (a: A) => TaskOption<B>): (ma: TaskOption<A>) => TaskOption<B>
  <A, B>(ma: TaskOption<A>, f: (a: A) => TaskOption<B>): TaskOption<B>
}

Added in v2.14.0 v2.14.0 中添加

flatMapIO   平面MapIO

Signature 签名

export declare const flatMapIO: {
  <A, B>(f: (a: A) => IO<B>): (self: TaskOption<A>) => TaskOption<B>
  <A, B>(self: TaskOption<A>, f: (a: A) => IO<B>): TaskOption<B>
}

Added in v2.16.0 v2.16.0 中添加

flatMapTask  平面地图任务

Signature 签名

export declare const flatMapTask: {
  <A, B>(f: (a: A) => T.Task<B>): (self: TaskOption<A>) => TaskOption<B>
  <A, B>(self: TaskOption<A>, f: (a: A) => T.Task<B>): TaskOption<B>
}

Added in v2.16.0 v2.16.0 中添加

flatten   压扁

Signature 签名

export declare const flatten: <A>(mma: TaskOption<TaskOption<A>>) => TaskOption<A>

Added in v2.10.0 v2.10.0 中添加

traversing   穿越

sequenceArray   序列数组

Equivalent to ReadonlyArray#sequence(Applicative). 相当于 ReadonlyArray#sequence(Applicative)

Signature 签名

export declare const sequenceArray: <A>(as: readonly TaskOption<A>[]) => TaskOption<readonly A[]>

Added in v2.10.0 v2.10.0 中添加

sequenceSeqArray   序列SeqArray

Equivalent to ReadonlyArray#sequence(ApplicativeSeq). 相当于 ReadonlyArray#sequence(ApplicativeSeq)

Signature 签名

export declare const sequenceSeqArray: <A>(as: readonly TaskOption<A>[]) => TaskOption<readonly A[]>

Added in v2.10.0 v2.10.0 中添加

traverseArray   遍历数组

Equivalent to ReadonlyArray#traverse(Applicative). 相当于 ReadonlyArray#traverse(Applicative)

Signature 签名

export declare const traverseArray: <A, B>(f: (a: A) => TaskOption<B>) => (as: readonly A[]) => TaskOption<readonly B[]>

Added in v2.10.0 v2.10.0 中添加

traverseArrayWithIndex   带索引遍历数组

Equivalent to ReadonlyArray#traverseWithIndex(Applicative). 相当于 ReadonlyArray#traverseWithIndex(Applicative)

Signature 签名

export declare const traverseArrayWithIndex: <A, B>(
  f: (index: number, a: A) => TaskOption<B>
) => (as: readonly A[]) => TaskOption<readonly B[]>

Added in v2.10.0 v2.10.0 中添加

traverseReadonlyArrayWithIndex
遍历带索引的只读数组

Equivalent to ReadonlyArray#traverseWithIndex(ApplicativePar). 相当于 ReadonlyArray#traverseWithIndex(ApplicativePar)

Signature 签名

export declare const traverseReadonlyArrayWithIndex: <A, B>(
  f: (index: number, a: A) => TaskOption<B>
) => (as: readonly A[]) => TaskOption<readonly B[]>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyArrayWithIndexSeq
遍历ReadonlyArrayWithIndexSeq

Equivalent to ReadonlyArray#traverseWithIndex(ApplicativeSeq). 相当于 ReadonlyArray#traverseWithIndex(ApplicativeSeq)

Signature 签名

export declare const traverseReadonlyArrayWithIndexSeq: <A, B>(
  f: (index: number, a: A) => TaskOption<B>
) => (as: readonly A[]) => TaskOption<readonly B[]>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyNonEmptyArrayWithIndex
遍历ReadonlyNonEmptyArrayWithIndex

Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar). 相当于 ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar)

Signature 签名

export declare const traverseReadonlyNonEmptyArrayWithIndex: <A, B>(
  f: (index: number, a: A) => TaskOption<B>
) => (as: ReadonlyNonEmptyArray<A>) => TaskOption<ReadonlyNonEmptyArray<B>>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyNonEmptyArrayWithIndexSeq
遍历ReadonlyNonEmptyArrayWithIndexSeq

Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq). 相当于 ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq)

Signature 签名

export declare const traverseReadonlyNonEmptyArrayWithIndexSeq: <A, B>(
  f: (index: number, a: A) => TaskOption<B>
) => (as: ReadonlyNonEmptyArray<A>) => TaskOption<ReadonlyNonEmptyArray<B>>

Added in v2.11.0 v2.11.0 中添加

traverseSeqArray   遍历SeqArray

Equivalent to ReadonlyArray#traverse(ApplicativeSeq). 相当于 ReadonlyArray#traverse(ApplicativeSeq)

Signature 签名

export declare const traverseSeqArray: <A, B>(
  f: (a: A) => TaskOption<B>
) => (as: readonly A[]) => TaskOption<readonly B[]>

Added in v2.10.0 v2.10.0 中添加

traverseSeqArrayWithIndex
带索引的遍历SeqArray

Equivalent to ReadonlyArray#traverseWithIndex(ApplicativeSeq). 相当于 ReadonlyArray#traverseWithIndex(ApplicativeSeq)

Signature 签名

export declare const traverseSeqArrayWithIndex: <A, B>(
  f: (index: number, a: A) => TaskOption<B>
) => (as: readonly A[]) => TaskOption<readonly B[]>

Added in v2.10.0 v2.10.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'TaskOption'

Added in v2.10.0 v2.10.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.10.0 v2.10.0 中添加

utils   实用程序

ApT   易于

Signature 签名

export declare const ApT: TaskOption<readonly []>

Added in v2.11.0 v2.11.0 中添加

ap   美联社

Signature 签名

export declare const ap: <A>(fa: TaskOption<A>) => <B>(fab: TaskOption<(a: A) => B>) => TaskOption<B>

Added in v2.10.0 v2.10.0 中添加

apFirst   应用程序第一

Combine two effectful actions, keeping only the result of the first.
结合两个有效的操作,仅保留第一个操作的结果。

Signature 签名

export declare const apFirst: <B>(second: TaskOption<B>) => <A>(first: TaskOption<A>) => TaskOption<A>

Added in v2.10.0 v2.10.0 中添加

apSecond   ap秒

Combine two effectful actions, keeping only the result of the second.
结合两个有效的操作,只保留第二个的结果。

Signature 签名

export declare const apSecond: <B>(second: TaskOption<B>) => <A>(first: TaskOption<A>) => TaskOption<B>

Added in v2.10.0 v2.10.0 中添加

zero  

Signature 签名

export declare const zero: <A>() => TaskOption<A>

Added in v2.10.0 v2.10.0 中添加

TaskThese overview  任务这些概述

Added in v2.4.0 v2.4.0中添加


Table of contents
目录


constructors  构造函数

both   两个都

Signature 签名

export declare const both: <E, A>(e: E, a: A) => TaskThese<E, A>

Added in v2.4.0 v2.4.0中添加

left  左边

Signature 签名

export declare const left: <E = never, A = never>(e: E) => TaskThese<E, A>

Added in v2.4.0 v2.4.0中添加

leftIO   左IO

Signature 签名

export declare const leftIO: <E = never, A = never>(me: IO<E>) => TaskThese<E, A>

Added in v2.4.0 v2.4.0中添加

leftTask   左任务

Signature 签名

export declare const leftTask: <E = never, A = never>(me: T.Task<E>) => TaskThese<E, A>

Added in v2.4.0 v2.4.0中添加

of  

Signature 签名

export declare const of: <E = never, A = never>(a: A) => TaskThese<E, A>

Added in v2.7.0 v2.7.0 中添加

Signature 签名

export declare const right: <E = never, A = never>(a: A) => TaskThese<E, A>

Added in v2.4.0 v2.4.0中添加

rightIO   右IO

Signature 签名

export declare const rightIO: <E = never, A = never>(ma: IO<A>) => TaskThese<E, A>

Added in v2.4.0 v2.4.0中添加

rightTask   正确的任务

Signature 签名

export declare const rightTask: <E = never, A = never>(ma: T.Task<A>) => TaskThese<E, A>

Added in v2.4.0 v2.4.0中添加

conversions   转换

fromEither   来自任一

Signature 签名

export declare const fromEither: <E, A>(fa: Either<E, A>) => TaskThese<E, A>

Added in v2.10.0 v2.10.0 中添加

fromIO   来自IO

Signature 签名

export declare const fromIO: <A, E = never>(fa: IO<A>) => TaskThese<E, A>

Added in v2.7.0 v2.7.0 中添加

fromIOEither   来自IOEither

Signature 签名

export declare const fromIOEither: <E, A>(fa: IOEither<E, A>) => TaskThese<E, A>

Added in v2.4.0 v2.4.0中添加

fromOption   来自选项

Signature 签名

export declare const fromOption: <E>(onNone: LazyArg<E>) => <A>(fa: Option<A>) => TaskThese<E, A>

Added in v2.10.0 v2.10.0 中添加

fromTask   来自任务

Signature 签名

export declare const fromTask: <A, E = never>(fa: T.Task<A>) => TaskThese<E, A>

Added in v2.7.0 v2.7.0 中添加

fromThese  来自这些

Signature 签名

export declare const fromThese: <E, A>(fa: TH.These<E, A>) => TaskThese<E, A>

Added in v2.11.0 v2.11.0 中添加

error handling   错误处理

mapLeft   地图左

Map a function over the first type argument of a bifunctor.
将函数映射到双函子的第一个类型参数上。

Signature 签名

export declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: TaskThese<E, A>) => TaskThese<G, A>

Added in v2.4.0 v2.4.0中添加

instances   实例

Bifunctor   双函子

Signature 签名

export declare const Bifunctor: Bifunctor2<'TaskThese'>

Added in v2.10.0 v2.10.0 中添加

FromEither   来自任一

Signature 签名

export declare const FromEither: FromEither2<'TaskThese'>

Added in v2.10.0 v2.10.0 中添加

FromIO   来自IO

Signature 签名

export declare const FromIO: FromIO2<'TaskThese'>

Added in v2.10.0 v2.10.0 中添加

FromTask   来自任务

Signature 签名

export declare const FromTask: FromTask2<'TaskThese'>

Added in v2.10.0 v2.10.0 中添加

FromThese  来自这些

Signature 签名

export declare const FromThese: FromThese2<'TaskThese'>

Added in v2.11.0 v2.11.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor2<'TaskThese'>

Added in v2.10.0 v2.10.0 中添加

Pointed  

Signature 签名

export declare const Pointed: Pointed2<'TaskThese'>

Added in v2.10.0 v2.10.0 中添加

getApplicative  获取应用程序

Signature 签名

export declare function getApplicative<E>(A: Apply1<T.URI>, S: Semigroup<E>): Applicative2C<URI, E>

Added in v2.7.0 v2.7.0 中添加

getApply   获取申请

Signature 签名

export declare const getApply: <E>(A: Apply1<T.URI>, S: Semigroup<E>) => Apply2C<'TaskThese', E>

Added in v2.10.0 v2.10.0 中添加

getChain   获取链

Signature 签名

export declare function getChain<E>(S: Semigroup<E>): Chain2C<URI, E>

Added in v2.10.0 v2.10.0 中添加

getMonad   获取单子

Signature 签名

export declare function getMonad<E>(S: Semigroup<E>): Monad2C<URI, E> & MonadTask2C<URI, E>

Added in v2.4.0 v2.4.0中添加

lifting   起重

fromIOK   来自IOK

Signature 签名

export declare const fromIOK: <A extends readonly unknown[], B>(
  f: (...a: A) => IO<B>
) => <E = never>(...a: A) => TaskThese<E, B>

Added in v2.10.0 v2.10.0 中添加

fromOptionK   来自选项K

Signature 签名

export declare const fromOptionK: <E>(
  onNone: LazyArg<E>
) => <A extends readonly unknown[], B>(f: (...a: A) => Option<B>) => (...a: A) => TaskThese<E, B>

Added in v2.10.0 v2.10.0 中添加

fromPredicate   来自谓词

Signature 签名

export declare const fromPredicate: {
  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => TaskThese<E, B>
  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => TaskThese<E, B>
  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => TaskThese<E, A>
}

Added in v2.10.0 v2.10.0 中添加

fromTaskK   来自任务K

Signature 签名

export declare const fromTaskK: <A extends readonly unknown[], B>(
  f: (...a: A) => T.Task<B>
) => <E = never>(...a: A) => TaskThese<E, B>

Added in v2.10.0 v2.10.0 中添加

fromTheseK  来自这些K

Signature 签名

export declare const fromTheseK: <A extends readonly unknown[], E, B>(
  f: (...a: A) => TH.These<E, B>
) => (...a: A) => TaskThese<E, B>

Added in v2.11.0 v2.11.0 中添加

mapping   映射

bimap   双图

Map a pair of functions over the two type arguments of the bifunctor.
将一对函数映射到双函子的两个类型参数上。

Signature 签名

export declare const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: TaskThese<E, A>) => TaskThese<G, B>

Added in v2.4.0 v2.4.0中添加

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <E, B>(fab: TaskThese<E, (a: A) => B>) => TaskThese<E, B>

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => <E>(fa: TaskThese<E, A>) => TaskThese<E, B>

Added in v2.4.0 v2.4.0中添加

model   模型

TaskThese (interface)  任务这些(界面)

Signature 签名

export interface TaskThese<E, A> extends Task<These<E, A>> {}

Added in v2.4.0 v2.4.0中添加

pattern matching   模式匹配

fold   折叠

Alias of matchE.  matchE 的别名。

Signature 签名

export declare const fold: <E, B, A>(
  onLeft: (e: E) => T.Task<B>,
  onRight: (a: A) => T.Task<B>,
  onBoth: (e: E, a: A) => T.Task<B>
) => (fa: TaskThese<E, A>) => T.Task<B>

Added in v2.4.0 v2.4.0中添加

foldW   折叠W

Alias of matchEW.  matchEW 的别名。

Signature 签名

export declare const foldW: <E, B, A, C, D>(
  onLeft: (e: E) => T.Task<B>,
  onRight: (a: A) => T.Task<C>,
  onBoth: (e: E, a: A) => T.Task<D>
) => (fa: TaskThese<E, A>) => T.Task<B | C | D>

Added in v2.10.0 v2.10.0 中添加

match   匹配

Signature 签名

export declare const match: <E, B, A>(
  onLeft: (e: E) => B,
  onRight: (a: A) => B,
  onBoth: (e: E, a: A) => B
) => (fa: TaskThese<E, A>) => T.Task<B>

Added in v2.10.0 v2.10.0 中添加

matchE   匹配E

The E suffix (short for Effect) means that the handlers return an effect (Task).
E 后缀(Effect 的缩写)意味着处理程序返回一个效果 ( Task )。

Signature 签名

export declare const matchE: <E, B, A>(
  onLeft: (e: E) => T.Task<B>,
  onRight: (a: A) => T.Task<B>,
  onBoth: (e: E, a: A) => T.Task<B>
) => (fa: TaskThese<E, A>) => T.Task<B>

Added in v2.10.0 v2.10.0 中添加

matchEW   匹配电子战

Less strict version of matchE.
matchE 的不太严格版本。

The W suffix (short for Widening) means that the handler return types will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const matchEW: <E, B, A, C, D>(
  onLeft: (e: E) => T.Task<B>,
  onRight: (a: A) => T.Task<C>,
  onBoth: (e: E, a: A) => T.Task<D>
) => (fa: TaskThese<E, A>) => T.Task<B | C | D>

Added in v2.10.0 v2.10.0 中添加

matchW   匹配W

Less strict version of match.
match 的不太严格版本。

The W suffix (short for Widening) means that the handler return types will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const matchW: <E, B, A, C, D>(
  onLeft: (e: E) => B,
  onRight: (a: A) => C,
  onBoth: (e: E, a: A) => D
) => (ma: TaskThese<E, A>) => T.Task<B | C | D>

Added in v2.10.0 v2.10.0 中添加

traversing   穿越

traverseReadonlyArrayWithIndex
遍历带索引的只读数组

Equivalent to ReadonlyArray#traverseWithIndex(getApplicative(T.ApplicativePar, S)). 相当于 ReadonlyArray#traverseWithIndex(getApplicative(T.ApplicativePar, S))

Signature 签名

export declare const traverseReadonlyArrayWithIndex: <E>(
  S: Semigroup<E>
) => <A, B>(f: (index: number, a: A) => TaskThese<E, B>) => (as: readonly A[]) => TaskThese<E, readonly B[]>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyArrayWithIndexSeq
遍历ReadonlyArrayWithIndexSeq

Equivalent to ReadonlyArray#traverseWithIndex(getApplicative(T.ApplicativeSeq, S)). 相当于 ReadonlyArray#traverseWithIndex(getApplicative(T.ApplicativeSeq, S))

Signature 签名

export declare const traverseReadonlyArrayWithIndexSeq: <E>(
  S: Semigroup<E>
) => <A, B>(f: (index: number, a: A) => TaskThese<E, B>) => (as: readonly A[]) => TaskThese<E, readonly B[]>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyNonEmptyArrayWithIndex
遍历ReadonlyNonEmptyArrayWithIndex

Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(getApplicative(T.ApplicativePar, S)). 相当于 ReadonlyNonEmptyArray#traverseWithIndex(getApplicative(T.ApplicativePar, S))

Signature 签名

export declare const traverseReadonlyNonEmptyArrayWithIndex: <E>(
  S: Semigroup<E>
) => <A, B>(
  f: (index: number, a: A) => TaskThese<E, B>
) => (as: ReadonlyNonEmptyArray<A>) => TaskThese<E, ReadonlyNonEmptyArray<B>>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyNonEmptyArrayWithIndexSeq
遍历ReadonlyNonEmptyArrayWithIndexSeq

Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(getApplicative(T.ApplicativeSeq, S)). 相当于 ReadonlyNonEmptyArray#traverseWithIndex(getApplicative(T.ApplicativeSeq, S))

Signature 签名

export declare const traverseReadonlyNonEmptyArrayWithIndexSeq: <E>(
  S: Semigroup<E>
) => <A, B>(
  f: (index: number, a: A) => TaskThese<E, B>
) => (as: ReadonlyNonEmptyArray<A>) => TaskThese<E, ReadonlyNonEmptyArray<B>>

Added in v2.11.0 v2.11.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'TaskThese'

Added in v2.4.0 v2.4.0中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.4.0 v2.4.0中添加

utils   实用程序

ApT   易于

Signature 签名

export declare const ApT: TaskThese<never, readonly []>

Added in v2.11.0 v2.11.0 中添加

swap   交换

Signature 签名

export declare const swap: <E, A>(fa: TaskThese<E, A>) => TaskThese<A, E>

Added in v2.4.0 v2.4.0中添加

toTuple2   元组2

Signature 签名

export declare const toTuple2: <E, A>(e: LazyArg<E>, a: LazyArg<A>) => (fa: TaskThese<E, A>) => T.Task<readonly [E, A]>

Added in v2.10.0 v2.10.0 中添加

zone of death
死亡地带

bifunctorTaskThese 双函子任务这些

Use Bifunctor instead. 请改用 Bifunctor

Signature 签名

export declare const bifunctorTaskThese: Bifunctor2<'TaskThese'>

Added in v2.7.0 v2.7.0 中添加

functorTaskThese 操作员任务这些

Use Functor instead. 请改用 Functor

Signature 签名

export declare const functorTaskThese: Functor2<'TaskThese'>

Added in v2.7.0 v2.7.0 中添加

getSemigroup 获取半群

Use getApplySemigroup instead. 请改用 getApplySemigroup

Signature 签名

export declare const getSemigroup: <E, A>(SE: Semigroup<E>, SA: Semigroup<A>) => Semigroup<TaskThese<E, A>>

Added in v2.4.0 v2.4.0中添加

taskThese 任务这些

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass TT.Functor instead of TT.taskThese (where TT is from import TT from 'fp-ts/TaskThese')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 TT.Functor 而不是 TT.taskThese (其中 TT 来自 import TT from 'fp-ts/TaskThese'

Signature 签名

export declare const taskThese: Functor2<'TaskThese'> & Bifunctor2<'TaskThese'>

Added in v2.4.0 v2.4.0中添加

toTuple 元组

Use toTuple2 instead. 请改用 toTuple2

Signature 签名

export declare const toTuple: <E, A>(e: E, a: A) => (fa: TaskThese<E, A>) => T.Task<[E, A]>

Added in v2.4.0 v2.4.0中添加

These overview  这些概述

A data structure providing “inclusive-or” as opposed to Either’s “exclusive-or”.
提供“包含或”而不是 Either 的“异或”的数据结构。

If you interpret Either<E, A> as suggesting the computation may either fail or succeed (exclusively), then These<E, A> may fail, succeed, or do both at the same time.
如果您将 Either<E, A> 解释为表明计算可能失败或成功(仅),则 These<E, A> 可能会失败、成功或同时执行两者。

There are a few ways to interpret the both case:
有几种方法可以解释这两种情况:

  • You can think of a computation that has a non-fatal error.
    您可以想象一个存在非致命错误的计算。
  • You can think of a computation that went as far as it could before erroring.
    您可以想象在出错之前尽可能进行的计算。
  • You can think of a computation that keeps track of errors as it completes.
    您可以想象一种在完成时跟踪错误的计算。

Another way you can think of These<E, A> is saying that we want to handle E kind of data, A kind of data, or both E and A kind of data at the same time. This is particularly useful when it comes to displaying UI’s.
您可以想到 These<E, A> 的另一种方式是说我们想要处理 E 类型的数据、 A 类型的数据、或者同时处理 EA 类型的数据。这在显示 UI 时特别有用。

(description adapted from https://package.elm-lang.org/packages/joneshf/elm-these)
(描述改编自https://package.elm-lang.org/packages/joneshf/elm-these)

Adapted from https://github.com/purescript-contrib/purescript-these
改编自 https://github.com/purescript-contrib/purescript-these

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


constructors  构造函数

both   两个都

Signature 签名

export declare function both<E, A>(left: E, right: A): These<E, A>

Added in v2.0.0 v2.0.0 中添加

left  左边

Signature 签名

export declare function left<E = never, A = never>(left: E): These<E, A>

Added in v2.0.0 v2.0.0 中添加

leftOrBoth   左或两者

Signature 签名

export declare function leftOrBoth<E>(e: E): <A>(ma: Option<A>) => These<E, A>

Example 例子

import { leftOrBoth, left, both } from 'fp-ts/These'
import { none, some } from 'fp-ts/Option'

assert.deepStrictEqual(leftOrBoth('a')(none), left('a'))
assert.deepStrictEqual(leftOrBoth('a')(some(1)), both('a', 1))

Added in v2.0.0 v2.0.0 中添加

of  

Signature 签名

export declare const of: <E = never, A = never>(right: A) => These<E, A>

Added in v2.0.0 v2.0.0 中添加

Signature 签名

export declare function right<E = never, A = never>(right: A): These<E, A>

Added in v2.0.0 v2.0.0 中添加

rightOrBoth   右或两者

Signature 签名

export declare function rightOrBoth<A>(a: A): <E>(me: Option<E>) => These<E, A>

Example 例子

import { rightOrBoth, right, both } from 'fp-ts/These'
import { none, some } from 'fp-ts/Option'

assert.deepStrictEqual(rightOrBoth(1)(none), right(1))
assert.deepStrictEqual(rightOrBoth(1)(some('a')), both('a', 1))

Added in v2.0.0 v2.0.0 中添加

conversions   转换

fromOption   来自选项

Signature 签名

export declare const fromOption: <E>(onNone: LazyArg<E>) => <A>(fa: Option<A>) => These<E, A>

Added in v2.10.0 v2.10.0 中添加

fromOptions   来自选项

Takes a pair of Options and attempts to create a These from them
获取一对 Option 并尝试从中创建 These

Signature 签名

export declare const fromOptions: <E, A>(fe: Option<E>, fa: Option<A>) => Option<These<E, A>>

Example 例子

import { fromOptions, left, right, both } from 'fp-ts/These'
import { none, some } from 'fp-ts/Option'

assert.deepStrictEqual(fromOptions(none, none), none)
assert.deepStrictEqual(fromOptions(some('a'), none), some(left('a')))
assert.deepStrictEqual(fromOptions(none, some(1)), some(right(1)))
assert.deepStrictEqual(fromOptions(some('a'), some(1)), some(both('a', 1)))

Added in v2.0.0 v2.0.0 中添加

getLeft   向左

Returns an E value if possible
如果可能,返回 E

Signature 签名

export declare function getLeft<E, A>(fa: These<E, A>): Option<E>

Example 例子

import { getLeft, left, right, both } from 'fp-ts/These'
import { none, some } from 'fp-ts/Option'

assert.deepStrictEqual(getLeft(left('a')), some('a'))
assert.deepStrictEqual(getLeft(right(1)), none)
assert.deepStrictEqual(getLeft(both('a', 1)), some('a'))

Added in v2.0.0 v2.0.0 中添加

getLeftOnly   只向左走

Returns the E value if and only if the value is constructed with Left
当且仅当该值是用 Left 构造的时才返回 E

Signature 签名

export declare function getLeftOnly<E, A>(fa: These<E, A>): Option<E>

Example 例子

import { getLeftOnly, left, right, both } from 'fp-ts/These'
import { none, some } from 'fp-ts/Option'

assert.deepStrictEqual(getLeftOnly(left('a')), some('a'))
assert.deepStrictEqual(getLeftOnly(right(1)), none)
assert.deepStrictEqual(getLeftOnly(both('a', 1)), none)

Added in v2.0.0 v2.0.0 中添加

getRight   得到正确的

Returns an A value if possible
如果可能,返回 A

Signature 签名

export declare function getRight<E, A>(fa: These<E, A>): Option<A>

Example 例子

import { getRight, left, right, both } from 'fp-ts/These'
import { none, some } from 'fp-ts/Option'

assert.deepStrictEqual(getRight(left('a')), none)
assert.deepStrictEqual(getRight(right(1)), some(1))
assert.deepStrictEqual(getRight(both('a', 1)), some(1))

Added in v2.0.0 v2.0.0 中添加

getRightOnly   只得到正确的

Returns the A value if and only if the value is constructed with Right
当且仅当该值是用 Right 构造的时才返回 A

Signature 签名

export declare function getRightOnly<E, A>(fa: These<E, A>): Option<A>

Example 例子

import { getRightOnly, left, right, both } from 'fp-ts/These'
import { none, some } from 'fp-ts/Option'

assert.deepStrictEqual(getRightOnly(left('a')), none)
assert.deepStrictEqual(getRightOnly(right(1)), some(1))
assert.deepStrictEqual(getRightOnly(both('a', 1)), none)

Added in v2.0.0 v2.0.0 中添加

toTuple2   元组2

Signature 签名

export declare const toTuple2: <E, A>(e: LazyArg<E>, a: LazyArg<A>) => (fa: These<E, A>) => readonly [E, A]

Example 例子

import { toTuple2, left, right, both } from 'fp-ts/These'

assert.deepStrictEqual(
  toTuple2(
    () => 'a',
    () => 1
  )(left('b')),
  ['b', 1]
)
assert.deepStrictEqual(
  toTuple2(
    () => 'a',
    () => 1
  )(right(2)),
  ['a', 2]
)
assert.deepStrictEqual(
  toTuple2(
    () => 'a',
    () => 1
  )(both('b', 2)),
  ['b', 2]
)

Added in v2.10.0 v2.10.0 中添加

error handling   错误处理

mapLeft   地图左

Map a function over the first type argument of a bifunctor.
将函数映射到双函子的第一个类型参数上。

Signature 签名

export declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: These<E, A>) => These<G, A>

Added in v2.0.0 v2.0.0 中添加

folding   折叠式的

foldMap   折叠图

Signature 签名

export declare const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <E>(fa: These<E, A>) => M

Added in v2.0.0 v2.0.0 中添加

reduce   减少

Signature 签名

export declare const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <E>(fa: These<E, A>) => B

Added in v2.0.0 v2.0.0 中添加

reduceRight   减少右

Signature 签名

export declare const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <E>(fa: These<E, A>) => B

Added in v2.0.0 v2.0.0 中添加

instances   实例

Bifunctor   双函子

Signature 签名

export declare const Bifunctor: Bifunctor2<'These'>

Added in v2.7.0 v2.7.0 中添加

Foldable   折叠式

Signature 签名

export declare const Foldable: Foldable2<'These'>

Added in v2.7.0 v2.7.0 中添加

FromEither   来自任一

Signature 签名

export declare const FromEither: FromEither2<'These'>

Added in v2.10.0 v2.10.0 中添加

FromThese  来自这些

Signature 签名

export declare const FromThese: FromThese2<'These'>

Added in v2.11.0 v2.11.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor2<'These'>

Added in v2.7.0 v2.7.0 中添加

Pointed  

Signature 签名

export declare const Pointed: Pointed2<'These'>

Added in v2.10.0 v2.10.0 中添加

Traversable   可穿越

Signature 签名

export declare const Traversable: Traversable2<'These'>

Added in v2.7.0 v2.7.0 中添加

getApplicative  获取应用程序

Signature 签名

export declare function getApplicative<E>(S: Semigroup<E>): Applicative2C<URI, E>

Added in v2.7.0 v2.7.0 中添加

getApply   获取申请

Signature 签名

export declare const getApply: <E>(S: Semigroup<E>) => Apply2C<'These', E>

Added in v2.10.0 v2.10.0 中添加

getChain   获取链

Signature 签名

export declare function getChain<E>(S: Semigroup<E>): Chain2C<URI, E>

Added in v2.10.0 v2.10.0 中添加

getEq   得到方程

Signature 签名

export declare function getEq<E, A>(EE: Eq<E>, EA: Eq<A>): Eq<These<E, A>>

Added in v2.0.0 v2.0.0 中添加

getMonad   获取单子

Signature 签名

export declare function getMonad<E>(S: Semigroup<E>): Monad2C<URI, E> & MonadThrow2C<URI, E>

Added in v2.0.0 v2.0.0 中添加

getSemigroup   获取半群

Signature 签名

export declare function getSemigroup<E, A>(SE: Semigroup<E>, SA: Semigroup<A>): Semigroup<These<E, A>>

Added in v2.0.0 v2.0.0 中添加

getShow   获取显示

Signature 签名

export declare function getShow<E, A>(SE: Show<E>, SA: Show<A>): Show<These<E, A>>

Added in v2.0.0 v2.0.0 中添加

lifting   起重

fromOptionK   来自选项K

Signature 签名

export declare const fromOptionK: <E>(
  onNone: LazyArg<E>
) => <A extends readonly unknown[], B>(f: (...a: A) => Option<B>) => (...a: A) => These<E, B>

Added in v2.10.0 v2.10.0 中添加

fromPredicate   来自谓词

Signature 签名

export declare const fromPredicate: {
  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => These<E, B>
  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => These<E, B>
  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => These<E, A>
}

Added in v2.13.0 v2.13.0 中添加

mapping   映射

bimap   双图

Map a pair of functions over the two type arguments of the bifunctor.
将一对函数映射到双函子的两个类型参数上。

Signature 签名

export declare const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: These<E, A>) => These<G, B>

Added in v2.0.0 v2.0.0 中添加

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <E, B>(fab: These<E, (a: A) => B>) => These<E, B>

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => <E>(fa: These<E, A>) => These<E, B>

Added in v2.0.0 v2.0.0 中添加

model   模型

Both (interface)  两者(接口)

Signature 签名

export interface Both<E, A> {
  readonly _tag: 'Both'
  readonly left: E
  readonly right: A
}

Added in v2.0.0 v2.0.0 中添加

These (type alias)
这些(类型别名)

Signature 签名

export type These<E, A> = Either<E, A> | Both<E, A>

Added in v2.0.0 v2.0.0 中添加

pattern matching   模式匹配

fold   折叠

Alias of match.  match 的别名。

Signature 签名

export declare const fold: <E, A, B>(
  onLeft: (e: E) => B,
  onRight: (a: A) => B,
  onBoth: (e: E, a: A) => B
) => (fa: These<E, A>) => B

Added in v2.0.0 v2.0.0 中添加

foldW   折叠W

Alias of matchW.  matchW 的别名。

Signature 签名

export declare const foldW: <E, B, A, C, D>(
  onLeft: (e: E) => B,
  onRight: (a: A) => C,
  onBoth: (e: E, a: A) => D
) => (fa: These<E, A>) => B | C | D

Added in v2.10.0 v2.10.0 中添加

match   匹配

Signature 签名

export declare const match: <E, A, B>(
  onLeft: (e: E) => B,
  onRight: (a: A) => B,
  onBoth: (e: E, a: A) => B
) => (fa: These<E, A>) => B

Added in v2.10.0 v2.10.0 中添加

matchW   匹配W

Less strict version of match.
match 的不太严格版本。

The W suffix (short for Widening) means that the handler return types will be merged.
W 后缀(Widening 的缩写)意味着处理程序返回类型将被合并。

Signature 签名

export declare const matchW: <E, B, A, C, D>(
  onLeft: (e: E) => B,
  onRight: (a: A) => C,
  onBoth: (e: E, a: A) => D
) => (fa: These<E, A>) => B | C | D

Added in v2.10.0 v2.10.0 中添加

refinements   改进

isBoth   既是

Returns true if the these is an instance of Both, false otherwise
如果它们是 Both 的实例,则返回 true ,否则返回 false

Signature 签名

export declare function isBoth<E, A>(fa: These<E, A>): fa is Both<E, A>

Added in v2.0.0 v2.0.0 中添加

isLeft   离开了

Returns true if the these is an instance of Left, false otherwise
如果它们是 Left 的实例,则返回 true ,否则返回 false

Signature 签名

export declare const isLeft: <E>(fa: These<E, unknown>) => fa is Left<E>

Added in v2.0.0 v2.0.0 中添加

isRight   是对的

Returns true if the these is an instance of Right, false otherwise
如果它们是 Right 的实例,则返回 true ,否则返回 false

Signature 签名

export declare const isRight: <A>(fa: These<unknown, A>) => fa is Right<A>

Added in v2.0.0 v2.0.0 中添加

traversing   穿越

sequence   顺序

Signature 签名

export declare const sequence: Sequence2<'These'>

Added in v2.6.3 v2.6.3 中添加

traverse   遍历

Signature 签名

export declare const traverse: PipeableTraverse2<'These'>

Added in v2.6.3 v2.6.3 中添加

traverseReadonlyArrayWithIndex
遍历带索引的只读数组

Equivalent to ReadonlyArray#traverseWithIndex(getApplicative(S)). 相当于 ReadonlyArray#traverseWithIndex(getApplicative(S))

Signature 签名

export declare const traverseReadonlyArrayWithIndex: <E>(
  S: Semigroup<E>
) => <A, B>(f: (index: number, a: A) => These<E, B>) => (as: readonly A[]) => These<E, readonly B[]>

Added in v2.11.0 v2.11.0 中添加

traverseReadonlyNonEmptyArrayWithIndex
遍历ReadonlyNonEmptyArrayWithIndex

Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(getApplicative(S)). 相当于 ReadonlyNonEmptyArray#traverseWithIndex(getApplicative(S))

Signature 签名

export declare const traverseReadonlyNonEmptyArrayWithIndex: <E>(
  S: Semigroup<E>
) => <A, B>(
  f: (index: number, a: A) => These<E, B>
) => (as: ReadonlyNonEmptyArray<A>) => These<E, ReadonlyNonEmptyArray<B>>

Added in v2.11.0 v2.11.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'These'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

ApT   易于

Signature 签名

export declare const ApT: These<never, readonly []>

Added in v2.11.0 v2.11.0 中添加

elem   埃莱姆

Signature 签名

export declare const elem: <A>(E: Eq<A>) => (a: A) => <E>(ma: These<E, A>) => boolean

Added in v2.11.0 v2.11.0 中添加

exists   存在

Signature 签名

export declare const exists: <A>(predicate: Predicate<A>) => (ma: These<unknown, A>) => boolean

Added in v2.11.0 v2.11.0 中添加

swap   交换

Signature 签名

export declare const swap: <E, A>(fa: These<E, A>) => These<A, E>

Added in v2.4.0 v2.4.0中添加

zone of death
死亡地带

these 这些

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass T.Functor instead of T.these (where T is from import T from 'fp-ts/These')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 T.Functor 而不是 T.these (其中 T 来自 import T from 'fp-ts/These'

Signature 签名

export declare const these: Functor2<'These'> & Bifunctor2<'These'> & Foldable2<'These'> & Traversable2<'These'>

Added in v2.0.0 v2.0.0 中添加

toTuple 元组

Use toTuple2 instead. 请改用 toTuple2

Signature 签名

export declare const toTuple: <E, A>(e: E, a: A) => (fa: These<E, A>) => [E, A]

Added in v2.0.0 v2.0.0 中添加

TheseT overview  这些概述

Added in v2.4.0 v2.4.0中添加


Table of contents
目录


utils   实用程序

ap   美联社

Signature 签名

export declare function ap<F extends URIS3, E>(
  F: Apply3<F>,
  S: Semigroup<E>
): <R, FE, A>(
  fa: Kind3<F, R, FE, These<E, A>>
) => <B>(fab: Kind3<F, R, FE, These<E, (a: A) => B>>) => Kind3<F, R, FE, These<E, B>>
export declare function ap<F extends URIS3, FE, E>(
  F: Apply3C<F, FE>,
  S: Semigroup<E>
): <R, A>(
  fa: Kind3<F, R, FE, These<E, A>>
) => <B>(fab: Kind3<F, R, FE, These<E, (a: A) => B>>) => Kind3<F, R, FE, These<E, B>>
export declare function ap<F extends URIS2, E>(
  F: Apply2<F>,
  S: Semigroup<E>
): <FE, A>(fa: Kind2<F, FE, These<E, A>>) => <B>(fab: Kind2<F, FE, These<E, (a: A) => B>>) => Kind2<F, FE, These<E, B>>
export declare function ap<F extends URIS2, FE, E>(
  F: Apply2C<F, FE>,
  S: Semigroup<E>
): <A>(fa: Kind2<F, FE, These<E, A>>) => <B>(fab: Kind2<F, FE, These<E, (a: A) => B>>) => Kind2<F, FE, These<E, B>>
export declare function ap<F extends URIS, E>(
  F: Apply1<F>,
  S: Semigroup<E>
): <A>(fa: Kind<F, These<E, A>>) => <B>(fab: Kind<F, These<E, (a: A) => B>>) => Kind<F, These<E, B>>
export declare function ap<F, E>(
  F: Apply<F>,
  S: Semigroup<E>
): <A>(fa: HKT<F, These<E, A>>) => <B>(fab: HKT<F, These<E, (a: A) => B>>) => HKT<F, These<E, B>>

Added in v2.10.0 v2.10.0 中添加

bimap   双图

Signature 签名

export declare function bimap<F extends URIS3>(
  F: Functor3<F>
): <E, G, A, B>(
  f: (e: E) => G,
  g: (a: A) => B
) => <R, FE>(fea: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, These<G, B>>
export declare function bimap<F extends URIS3, FE>(
  F: Functor3C<F, FE>
): <E, G, A, B>(
  f: (e: E) => G,
  g: (a: A) => B
) => <R>(fea: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, These<G, B>>
export declare function bimap<F extends URIS2>(
  F: Functor2<F>
): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => <FE>(fea: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, These<G, B>>
export declare function bimap<F extends URIS2, FE>(
  F: Functor2C<F, FE>
): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fea: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, These<G, B>>
export declare function bimap<F extends URIS>(
  F: Functor1<F>
): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fea: Kind<F, These<E, A>>) => Kind<F, These<G, B>>
export declare function bimap<F>(
  F: Functor<F>
): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fea: HKT<F, These<E, A>>) => HKT<F, These<G, B>>

Added in v2.10.0 v2.10.0 中添加

both   两个都

Signature 签名

export declare function both<F extends URIS3>(F: Pointed3<F>): <E, A, S, R>(e: E, a: A) => Kind3<F, S, R, These<E, A>>
export declare function both<F extends URIS3, R>(F: Pointed3C<F, R>): <E, A>(e: E, a: A) => Kind3<F, R, R, These<E, A>>
export declare function both<F extends URIS2>(F: Pointed2<F>): <E, A, R>(e: E, a: A) => Kind2<F, R, These<E, A>>
export declare function both<F extends URIS2, R>(F: Pointed2C<F, R>): <E, A>(e: E, a: A) => Kind2<F, R, These<E, A>>
export declare function both<F extends URIS>(F: Pointed1<F>): <E, A>(e: E, a: A) => Kind<F, These<E, A>>
export declare function both<F>(F: Pointed<F>): <E, A = never>(e: E, a: A) => HKT<F, These<E, A>>

Added in v2.10.0 v2.10.0 中添加

chain  

Signature 签名

export declare function chain<M extends URIS3, E>(
  M: Monad3<M>,
  S: Semigroup<E>
): <A, R, ME, B>(
  f: (a: A) => Kind3<M, R, ME, These<E, B>>
) => (ma: Kind3<M, R, ME, These<E, A>>) => Kind3<M, R, ME, These<E, B>>
export declare function chain<M extends URIS3, ME, E>(
  M: Monad3C<M, ME>,
  S: Semigroup<E>
): <A, R, B>(
  f: (a: A) => Kind3<M, R, ME, These<E, B>>
) => (ma: Kind3<M, R, ME, These<E, A>>) => Kind3<M, R, ME, These<E, B>>
export declare function chain<M extends URIS2, E>(
  M: Monad2<M>,
  S: Semigroup<E>
): <A, ME, B>(f: (a: A) => Kind2<M, ME, These<E, B>>) => (ma: Kind2<M, ME, These<E, A>>) => Kind2<M, ME, These<E, B>>
export declare function chain<M extends URIS2, ME, E>(
  M: Monad2C<M, ME>,
  S: Semigroup<E>
): <A, B>(f: (a: A) => Kind2<M, ME, These<E, B>>) => (ma: Kind2<M, ME, These<E, A>>) => Kind2<M, ME, These<E, B>>
export declare function chain<M extends URIS, E>(
  M: Monad1<M>,
  S: Semigroup<E>
): <A, B>(f: (a: A) => Kind<M, These<E, B>>) => (ma: Kind<M, These<E, A>>) => Kind<M, These<E, B>>
export declare function chain<M, E>(
  M: Monad<M>,
  S: Semigroup<E>
): <A, B>(f: (a: A) => HKT<M, These<E, B>>) => (ma: HKT<M, These<E, A>>) => HKT<M, These<E, B>>

Added in v2.10.0 v2.10.0 中添加

left  左边

Signature 签名

export declare function left<F extends URIS3>(
  F: Pointed3<F>
): <E, R, FE, A = never>(e: E) => Kind3<F, R, FE, These<E, A>>
export declare function left<F extends URIS3, FE>(
  F: Pointed3C<F, FE>
): <E, R, A = never>(e: E) => Kind3<F, R, FE, These<E, A>>
export declare function left<F extends URIS2>(F: Pointed2<F>): <E, FE, A = never>(e: E) => Kind2<F, FE, These<E, A>>
export declare function left<F extends URIS2, FE>(
  F: Pointed2C<F, FE>
): <E, A = never>(e: E) => Kind2<F, FE, These<E, A>>
export declare function left<F extends URIS>(F: Pointed1<F>): <E, A = never>(e: E) => Kind<F, These<E, A>>
export declare function left<F>(F: Pointed<F>): <E, A = never>(e: E) => HKT<F, These<E, A>>

Added in v2.10.0 v2.10.0 中添加

leftF   左F

Signature 签名

export declare function leftF<F extends URIS3>(
  F: Functor3<F>
): <R, FE, E, A = never>(fe: Kind3<F, R, FE, E>) => Kind3<F, R, FE, These<E, A>>
export declare function leftF<F extends URIS3, FE>(
  F: Functor3C<F, FE>
): <R, E, A = never>(fe: Kind3<F, R, FE, E>) => Kind3<F, R, FE, These<E, A>>
export declare function leftF<F extends URIS2>(
  F: Functor2<F>
): <FE, E, A = never>(fe: Kind2<F, FE, E>) => Kind2<F, FE, These<E, A>>
export declare function leftF<F extends URIS2, FE>(
  F: Functor2C<F, FE>
): <E, A = never>(fe: Kind2<F, FE, E>) => Kind2<F, FE, These<E, A>>
export declare function leftF<F extends URIS>(F: Functor1<F>): <E, A = never>(fe: Kind<F, E>) => Kind<F, These<E, A>>
export declare function leftF<F>(F: Functor<F>): <E, A = never>(fe: HKT<F, E>) => HKT<F, These<E, A>>

Added in v2.10.0 v2.10.0 中添加

map   地图

Signature 签名

export declare function map<F extends URIS3>(
  F: Functor3<F>
): <A, B>(f: (a: A) => B) => <R, FE, E>(fa: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, These<E, B>>
export declare function map<F extends URIS3, FE>(
  F: Functor3C<F, FE>
): <A, B>(f: (a: A) => B) => <R, E>(fa: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, These<E, B>>
export declare function map<F extends URIS2>(
  F: Functor2<F>
): <A, B>(f: (a: A) => B) => <FE, E>(fa: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, These<E, B>>
export declare function map<F extends URIS2, FE>(
  F: Functor2C<F, FE>
): <A, B>(f: (a: A) => B) => <E>(fa: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, These<E, B>>
export declare function map<F extends URIS>(
  F: Functor1<F>
): <A, B>(f: (a: A) => B) => <E>(fa: Kind<F, These<E, A>>) => Kind<F, These<E, B>>
export declare function map<F>(
  F: Functor<F>
): <A, B>(f: (a: A) => B) => <E>(fa: HKT<F, These<E, A>>) => HKT<F, These<E, B>>

Added in v2.10.0 v2.10.0 中添加

mapLeft   地图左

Signature 签名

export declare function mapLeft<F extends URIS3>(
  F: Functor3<F>
): <E, G>(f: (e: E) => G) => <R, FE, A>(fea: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, These<G, A>>
export declare function mapLeft<F extends URIS3, FE>(
  F: Functor3C<F, FE>
): <E, G>(f: (e: E) => G) => <R, A>(fea: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, These<G, A>>
export declare function mapLeft<F extends URIS2>(
  F: Functor2<F>
): <E, G>(f: (e: E) => G) => <FE, A>(fea: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, These<G, A>>
export declare function mapLeft<F extends URIS2, FE>(
  F: Functor2C<F, FE>
): <E, G>(f: (e: E) => G) => <A>(fea: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, These<G, A>>
export declare function mapLeft<F extends URIS>(
  F: Functor1<F>
): <E, G>(f: (e: E) => G) => <A>(fea: Kind<F, These<E, A>>) => Kind<F, These<G, A>>
export declare function mapLeft<F>(
  F: Functor<F>
): <E, G>(f: (e: E) => G) => <A>(fea: HKT<F, These<E, A>>) => HKT<F, These<G, A>>

Added in v2.10.0 v2.10.0 中添加

match   匹配

Signature 签名

export declare function match<F extends URIS3>(
  F: Functor3<F>
): <E, B, A>(
  onLeft: (e: E) => B,
  onRight: (a: A) => B,
  onBoth: (e: E, a: A) => B
) => <S, R>(ma: Kind3<F, S, R, These<E, A>>) => Kind3<F, S, R, B>
export declare function match<F extends URIS3, R>(
  F: Functor3C<F, R>
): <E, B, A>(
  onLeft: (e: E) => B,
  onRight: (a: A) => B,
  onBoth: (e: E, a: A) => B
) => <S>(ma: Kind3<F, S, R, These<E, A>>) => Kind3<F, S, R, B>
export declare function match<F extends URIS2>(
  F: Functor2<F>
): <E, B, A>(
  onLeft: (e: E) => B,
  onRight: (a: A) => B,
  onBoth: (e: E, a: A) => B
) => <R>(ma: Kind2<F, R, These<E, A>>) => Kind2<F, R, B>
export declare function match<M extends URIS2, R>(
  F: Functor2C<M, R>
): <E, B, A>(
  onLeft: (e: E) => B,
  onRight: (a: A) => B,
  onBoth: (e: E, a: A) => B
) => (ma: Kind2<M, R, These<E, A>>) => Kind2<M, R, B>
export declare function match<F extends URIS>(
  F: Functor1<F>
): <E, B, A>(
  onLeft: (e: E) => B,
  onRight: (a: A) => B,
  onBoth: (e: E, a: A) => B
) => (ma: Kind<F, These<E, A>>) => Kind<F, B>
export declare function match<F>(
  F: Functor<F>
): <E, B, A>(
  onLeft: (e: E) => B,
  onRight: (a: A) => B,
  onBoth: (e: E, a: A) => B
) => (ma: HKT<F, These<E, A>>) => HKT<F, B>

Added in v2.10.0 v2.10.0 中添加

matchE   匹配E

Signature 签名

export declare function matchE<M extends URIS3>(
  M: Chain3<M>
): <E, R, ME, B, A>(
  onLeft: (e: E) => Kind3<M, R, ME, B>,
  onRight: (a: A) => Kind3<M, R, ME, B>,
  onBoth: (e: E, a: A) => Kind3<M, R, ME, B>
) => (ma: Kind3<M, R, ME, These<E, A>>) => Kind3<M, R, ME, B>
export declare function matchE<M extends URIS3, ME>(
  M: Chain3C<M, ME>
): <E, R, B, A>(
  onLeft: (e: E) => Kind3<M, R, ME, B>,
  onRight: (a: A) => Kind3<M, R, ME, B>,
  onBoth: (e: E, a: A) => Kind3<M, R, ME, B>
) => (ma: Kind3<M, R, ME, These<E, A>>) => Kind3<M, R, ME, B>
export declare function matchE<M extends URIS2>(
  M: Chain2<M>
): <E, ME, B, A>(
  onLeft: (e: E) => Kind2<M, ME, B>,
  onRight: (a: A) => Kind2<M, ME, B>,
  onBoth: (e: E, a: A) => Kind2<M, ME, B>
) => (ma: Kind2<M, ME, These<E, A>>) => Kind2<M, ME, B>
export declare function matchE<M extends URIS2, ME>(
  M: Chain2C<M, ME>
): <E, B, A>(
  onLeft: (e: E) => Kind2<M, ME, B>,
  onRight: (a: A) => Kind2<M, ME, B>,
  onBoth: (e: E, a: A) => Kind2<M, ME, B>
) => (ma: Kind2<M, ME, These<E, A>>) => Kind2<M, ME, B>
export declare function matchE<M extends URIS>(
  M: Chain1<M>
): <E, B, A>(
  onLeft: (e: E) => Kind<M, B>,
  onRight: (a: A) => Kind<M, B>,
  onBoth: (e: E, a: A) => Kind<M, B>
) => (ma: Kind<M, These<E, A>>) => Kind<M, B>
export declare function matchE<M>(
  M: Chain<M>
): <E, B, A>(
  onLeft: (e: E) => HKT<M, B>,
  onRight: (a: A) => HKT<M, B>,
  onBoth: (e: E, a: A) => HKT<M, B>
) => (ma: HKT<M, These<E, A>>) => HKT<M, B>

Added in v2.10.0 v2.10.0 中添加

Signature 签名

export declare function right<F extends URIS3>(
  F: Pointed3<F>
): <A, R, FE, E = never>(a: A) => Kind3<F, R, FE, These<E, A>>
export declare function right<F extends URIS3, FE>(
  F: Pointed3C<F, FE>
): <A, R, E = never>(a: A) => Kind3<F, R, FE, These<E, A>>
export declare function right<F extends URIS2>(F: Pointed2<F>): <A, FE, E = never>(a: A) => Kind2<F, FE, These<E, A>>
export declare function right<F extends URIS2, FE>(
  F: Pointed2C<F, FE>
): <A, E = never>(a: A) => Kind2<F, FE, These<E, A>>
export declare function right<F extends URIS>(F: Pointed1<F>): <A, E = never>(a: A) => Kind<F, These<E, A>>
export declare function right<F>(F: Pointed<F>): <A, E = never>(a: A) => HKT<F, These<E, A>>

Added in v2.10.0 v2.10.0 中添加

rightF   右F

Signature 签名

export declare function rightF<F extends URIS3>(
  F: Functor3<F>
): <R, FE, A, E = never>(fa: Kind3<F, R, FE, A>) => Kind3<F, R, FE, These<E, A>>
export declare function rightF<F extends URIS3, FE>(
  F: Functor3C<F, FE>
): <R, A, E = never>(fa: Kind3<F, R, FE, A>) => Kind3<F, R, FE, These<E, A>>
export declare function rightF<F extends URIS2>(
  F: Functor2<F>
): <FE, A, E = never>(fa: Kind2<F, FE, A>) => Kind2<F, FE, These<E, A>>
export declare function rightF<F extends URIS2, FE>(
  F: Functor2C<F, FE>
): <A, E = never>(fa: Kind2<F, FE, A>) => Kind2<F, FE, These<E, A>>
export declare function rightF<F extends URIS>(F: Functor1<F>): <A, E = never>(fa: Kind<F, A>) => Kind<F, These<E, A>>
export declare function rightF<F>(F: Functor<F>): <A, E = never>(fa: HKT<F, A>) => HKT<F, These<E, A>>

Added in v2.10.0 v2.10.0 中添加

swap   交换

Signature 签名

export declare function swap<F extends URIS3>(
  F: Functor3<F>
): <R, FE, E, A>(ma: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, These<A, E>>
export declare function swap<F extends URIS3, FE>(
  F: Functor3C<F, FE>
): <R, E, A>(ma: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, These<A, E>>
export declare function swap<F extends URIS2>(
  F: Functor2<F>
): <FE, E, A>(ma: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, These<A, E>>
export declare function swap<F extends URIS2, FE>(
  F: Functor2C<F, FE>
): <E, A>(ma: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, These<A, E>>
export declare function swap<F extends URIS>(F: Functor1<F>): <E, A>(ma: Kind<F, These<E, A>>) => Kind<F, These<A, E>>
export declare function swap<F>(F: Functor<F>): <E, A>(ma: HKT<F, These<E, A>>) => HKT<F, These<A, E>>

Added in v2.10.0 v2.10.0 中添加

toTuple2   元组2

Signature 签名

export declare function toTuple2<F extends URIS3>(
  F: Functor3<F>
): <E, A>(e: LazyArg<E>, a: LazyArg<A>) => <R, FE>(fa: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, readonly [E, A]>
export declare function toTuple2<F extends URIS3, FE>(
  F: Functor3C<F, FE>
): <E, A>(e: LazyArg<E>, a: LazyArg<A>) => <R>(fa: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, readonly [E, A]>
export declare function toTuple2<F extends URIS2>(
  F: Functor2<F>
): <E, A>(e: LazyArg<E>, a: LazyArg<A>) => <FE>(fa: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, readonly [E, A]>
export declare function toTuple2<F extends URIS2, FE>(
  F: Functor2C<F, FE>
): <E, A>(e: LazyArg<E>, a: LazyArg<A>) => (fa: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, readonly [E, A]>
export declare function toTuple2<F extends URIS>(
  F: Functor1<F>
): <E, A>(e: LazyArg<E>, a: LazyArg<A>) => (fa: Kind<F, These<E, A>>) => Kind<F, readonly [E, A]>
export declare function toTuple2<F>(
  F: Functor<F>
): <E, A>(e: LazyArg<E>, a: LazyArg<A>) => (fa: HKT<F, These<E, A>>) => HKT<F, readonly [E, A]>

Added in v2.10.0 v2.10.0 中添加

zone of death
死亡地带

TheseM1 这些M1 (interface)   (界面)

Signature 签名

export interface TheseM1<M extends URIS> {
  readonly map: <E, A, B>(fa: TheseT1<M, E, A>, f: (a: A) => B) => TheseT1<M, E, B>
  readonly bimap: <E, A, N, B>(fa: TheseT1<M, E, A>, f: (e: E) => N, g: (a: A) => B) => TheseT1<M, N, B>
  readonly mapLeft: <E, A, N>(fa: TheseT1<M, E, A>, f: (e: E) => N) => TheseT1<M, N, A>
  readonly fold: <E, A, R>(
    fa: TheseT1<M, E, A>,
    onLeft: (e: E) => Kind<M, R>,
    onRight: (a: A) => Kind<M, R>,
    onBoth: (e: E, a: A) => Kind<M, R>
  ) => Kind<M, R>
  readonly swap: <E, A>(fa: TheseT1<M, E, A>) => TheseT1<M, A, E>
  readonly rightM: <E, A>(ma: Kind<M, A>) => TheseT1<M, E, A>
  readonly leftM: <E, A>(me: Kind<M, E>) => TheseT1<M, E, A>
  readonly left: <E, A>(e: E) => TheseT1<M, E, A>
  readonly right: <E, A>(a: A) => TheseT1<M, E, A>
  readonly both: <E, A>(e: E, a: A) => TheseT1<M, E, A>
  readonly toTuple: <E, A>(fa: TheseT1<M, E, A>, e: E, a: A) => Kind<M, [E, A]>
  readonly getMonad: <E>(S: Semigroup<E>) => {
    readonly _E: E
    readonly map: <A, B>(ma: TheseT1<M, E, A>, f: (a: A) => B) => TheseT1<M, E, B>
    readonly of: <A>(a: A) => TheseT1<M, E, A>
    readonly ap: <A, B>(mab: TheseT1<M, E, (a: A) => B>, ma: TheseT1<M, E, A>) => TheseT1<M, E, B>
    readonly chain: <A, B>(ma: TheseT1<M, E, A>, f: (a: A) => TheseT1<M, E, B>) => TheseT1<M, E, B>
  }
}

Added in v2.4.0 v2.4.0中添加

TheseM2 这些M2 (interface)   (界面)

Signature 签名

export interface TheseM2<M extends URIS2> {
  readonly map: <R, E, A, B>(fa: TheseT2<M, R, E, A>, f: (a: A) => B) => TheseT2<M, R, E, B>
  readonly bimap: <R, E, A, N, B>(fa: TheseT2<M, R, E, A>, f: (e: E) => N, g: (a: A) => B) => TheseT2<M, R, N, B>
  readonly mapLeft: <R, E, A, N>(fa: TheseT2<M, R, E, A>, f: (e: E) => N) => TheseT2<M, R, N, A>
  readonly fold: <R, E, A, B>(
    fa: TheseT2<M, R, E, A>,
    onLeft: (e: E) => Kind2<M, R, B>,
    onRight: (a: A) => Kind2<M, R, B>,
    onBoth: (e: E, a: A) => Kind2<M, R, B>
  ) => Kind2<M, R, B>
  readonly swap: <R, E, A>(fa: TheseT2<M, R, E, A>) => TheseT2<M, R, A, E>
  readonly rightM: <R, E, A>(ma: Kind2<M, R, A>) => TheseT2<M, R, E, A>
  readonly leftM: <R, E, A>(me: Kind2<M, R, E>) => TheseT2<M, R, E, A>
  readonly left: <R, E, A>(e: E) => TheseT2<M, R, E, A>
  readonly right: <R, E, A>(a: A) => TheseT2<M, R, E, A>
  readonly both: <R, E, A>(e: E, a: A) => TheseT2<M, R, E, A>
  readonly toTuple: <R, E, A>(fa: TheseT2<M, R, E, A>, e: E, a: A) => Kind2<M, R, [E, A]>
  readonly getMonad: <E>(S: Semigroup<E>) => {
    readonly _E: E
    readonly map: <R, A, B>(ma: TheseT2<M, R, E, A>, f: (a: A) => B) => TheseT2<M, R, E, B>
    readonly of: <R, A>(a: A) => TheseT2<M, R, E, A>
    readonly ap: <R, A, B>(mab: TheseT2<M, R, E, (a: A) => B>, ma: TheseT2<M, R, E, A>) => TheseT2<M, R, E, B>
    readonly chain: <R, A, B>(ma: TheseT2<M, R, E, A>, f: (a: A) => TheseT2<M, R, E, B>) => TheseT2<M, R, E, B>
  }
}

Added in v2.4.0 v2.4.0中添加

TheseM 这些M (interface)   (界面)

Signature 签名

export interface TheseM<M> {
  readonly map: <E, A, B>(fa: TheseT<M, E, A>, f: (a: A) => B) => TheseT<M, E, B>
  readonly bimap: <E, A, N, B>(fa: TheseT<M, E, A>, f: (e: E) => N, g: (a: A) => B) => TheseT<M, N, B>
  readonly mapLeft: <E, A, N>(fa: TheseT<M, E, A>, f: (e: E) => N) => TheseT<M, N, A>
  readonly fold: <E, A, R>(
    fa: TheseT<M, E, A>,
    onLeft: (e: E) => HKT<M, R>,
    onRight: (a: A) => HKT<M, R>,
    onBoth: (e: E, a: A) => HKT<M, R>
  ) => HKT<M, R>
  readonly swap: <E, A>(fa: TheseT<M, E, A>) => TheseT<M, A, E>
  readonly rightM: <E, A>(ma: HKT<M, A>) => TheseT<M, E, A>
  readonly leftM: <E, A>(me: HKT<M, E>) => TheseT<M, E, A>
  readonly left: <E, A>(e: E) => TheseT<M, E, A>
  readonly right: <E, A>(a: A) => TheseT<M, E, A>
  readonly both: <E, A>(e: E, a: A) => TheseT<M, E, A>
  readonly toTuple: <E, A>(fa: TheseT<M, E, A>, e: E, a: A) => HKT<M, [E, A]>
  readonly getMonad: <E>(S: Semigroup<E>) => {
    readonly _E: E
    readonly map: <A, B>(ma: TheseT<M, E, A>, f: (a: A) => B) => TheseT<M, E, B>
    readonly of: <A>(a: A) => TheseT<M, E, A>
    readonly ap: <A, B>(mab: TheseT<M, E, (a: A) => B>, ma: TheseT<M, E, A>) => TheseT<M, E, B>
    readonly chain: <A, B>(ma: TheseT<M, E, A>, f: (a: A) => TheseT<M, E, B>) => TheseT<M, E, B>
  }
}

Added in v2.4.0 v2.4.0中添加

TheseT1 这些T1 (type alias)   (类型别名)

Signature 签名

export type TheseT1<M extends URIS, E, A> = Kind<M, These<E, A>>

Added in v2.4.0 v2.4.0中添加

TheseT2 这些T2 (type alias)   (类型别名)

Signature 签名

export type TheseT2<M extends URIS2, R, E, A> = Kind2<M, R, These<E, A>>

Added in v2.4.0 v2.4.0中添加

TheseT 这些T (interface)   (界面)

Signature 签名

export interface TheseT<M, E, A> extends HKT<M, These<E, A>> {}

Added in v2.4.0 v2.4.0中添加

getTheseM 得到这些M

Signature 签名

export declare function getTheseM<M extends URIS2>(M: Monad2<M>): TheseM2<M>
export declare function getTheseM<M extends URIS>(M: Monad1<M>): TheseM1<M>
export declare function getTheseM<M>(M: Monad<M>): TheseM<M>

Added in v2.4.0 v2.4.0中添加

Traced overview  追踪概述

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


instances   实例

Functor   函子

Signature 签名

export declare const Functor: Functor2<'Traced'>

Added in v2.7.0 v2.7.0 中添加

getComonad   获取Comonad

Signature 签名

export declare function getComonad<P>(monoid: Monoid<P>): Comonad2C<URI, P>

Added in v2.0.0 v2.0.0 中添加

mapping   映射

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <E, B>(fab: Traced<E, (a: A) => B>) => Traced<E, B>

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => <E>(fa: Traced<E, A>) => Traced<E, B>

Added in v2.0.0 v2.0.0 中添加

model   模型

Traced (interface)   追踪(界面)

Signature 签名

export interface Traced<P, A> {
  (p: P): A
}

Added in v2.0.0 v2.0.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'Traced'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

censor   审查

Apply a function to the current position
将函数应用到当前位置

Signature 签名

export declare function censor<P>(f: (p: P) => P): <A>(wa: Traced<P, A>) => Traced<P, A>

Added in v2.0.0 v2.0.0 中添加

listen  

Get the current position
获取当前位置

Signature 签名

export declare function listen<P, A>(wa: Traced<P, A>): Traced<P, [A, P]>

Added in v2.0.0 v2.0.0 中添加

listens  

Get a value which depends on the current position
获取取决于当前位置的值

Signature 签名

export declare function listens<P, B>(f: (p: P) => B): <A>(wa: Traced<P, A>) => Traced<P, [A, B]>

Added in v2.0.0 v2.0.0 中添加

tracks   曲目

Extracts a value at a relative position which depends on the current value.
提取取决于当前值的相对位置处的值。

Signature 签名

export declare function tracks<P, A>(M: Monoid<P>, f: (a: A) => P): (wa: Traced<P, A>) => A

Added in v2.0.0 v2.0.0 中添加

zone of death
死亡地带

traced 追踪到的

Use Functor instead. 请改用 Functor

Signature 签名

export declare const traced: Functor2<'Traced'>

Added in v2.0.0 v2.0.0 中添加

Traversable overview  可穿越概述

Traversable represents data structures which can be traversed accumulating results and effects in some Applicative functor.
Traversable 表示可以遍历的数据结构,在某些 Applicative 函子中累积结果和效果。

  • traverse runs an action for every element in a data structure, and accumulates the results.
    traverse 对数据结构中的每个元素运行一个操作,并累积结果。
  • sequence runs the actions contained in a data structure, and accumulates the results.
    sequence 运行数据结构中包含的操作,并累积结果。

The traverse and sequence functions should be compatible in the following sense:
traversesequence 函数应该在以下意义上兼容:

  • traverse(A)(xs, f) <-> sequence(A)(A.map(xs, f))
  • sequence(A)(xs) <-> traverse(A)(xs, identity)

where A is an Applicative instance
其中 AApplicative 实例

Traversable instances should also be compatible with the corresponding Foldable instances, in the following sense:
Traversable 实例也应该与相应的 Foldable 实例兼容,在以下意义上:

import { getApplicative, make } from 'fp-ts/Const'

const A = getApplicative(M)

foldMap(M)(xs, f) = traverse(A)(xs, (a) => make(f(a)))

where M is a Monoid instance
其中 MMonoid 实例

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Traversable (interface)
可遍历(接口)

Signature 签名

export interface Traversable<T> extends Functor<T>, Foldable<T> {
  /**
   * Runs an action for every element in a data structure and accumulates the results
   */
  readonly traverse: Traverse<T>
  readonly sequence: Sequence<T>
}

Added in v2.0.0 v2.0.0 中添加

Traversable1 (interface)
可遍历1(接口)

Signature 签名

export interface Traversable1<T extends URIS> extends Functor1<T>, Foldable1<T> {
  readonly traverse: Traverse1<T>
  readonly sequence: Sequence1<T>
}

Added in v2.0.0 v2.0.0 中添加

Traversable2 (interface)
可遍历2(接口)

Signature 签名

export interface Traversable2<T extends URIS2> extends Functor2<T>, Foldable2<T> {
  readonly traverse: Traverse2<T>
  readonly sequence: Sequence2<T>
}

Added in v2.0.0 v2.0.0 中添加

Traversable2C (interface)
Traversable2C(接口)

Signature 签名

export interface Traversable2C<T extends URIS2, TL> extends Functor2C<T, TL>, Foldable2C<T, TL> {
  readonly traverse: Traverse2C<T, TL>
  readonly sequence: Sequence2C<T, TL>
}

Added in v2.0.0 v2.0.0 中添加

Traversable3 (interface)
Traversable3(接口)

Signature 签名

export interface Traversable3<T extends URIS3> extends Functor3<T>, Foldable3<T> {
  readonly traverse: Traverse3<T>
  readonly sequence: Sequence3<T>
}

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

PipeableTraverse1 (interface)
PipeableTraverse1(接口)

Signature 签名

export interface PipeableTraverse1<T extends URIS> {
  <F extends URIS3>(F: Applicative3<F>): <A, FR, FE, B>(
    f: (a: A) => Kind3<F, FR, FE, B>
  ) => (ta: Kind<T, A>) => Kind3<F, FR, FE, Kind<T, B>>
  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <A, FR, B>(
    f: (a: A) => Kind3<F, FR, FE, B>
  ) => (ta: Kind<T, A>) => Kind3<F, FR, FE, Kind<T, B>>
  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(
    f: (a: A) => Kind2<F, FE, B>
  ) => (ta: Kind<T, A>) => Kind2<F, FE, Kind<T, B>>
  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(
    f: (a: A) => Kind2<F, FE, B>
  ) => (ta: Kind<T, A>) => Kind2<F, FE, Kind<T, B>>
  <F extends URIS>(F: Applicative1<F>): <A, B>(f: (a: A) => Kind<F, B>) => (ta: Kind<T, A>) => Kind<F, Kind<T, B>>
  <F>(F: Applicative<F>): <A, B>(f: (a: A) => HKT<F, B>) => (ta: Kind<T, A>) => HKT<F, Kind<T, B>>
}

Added in v2.6.3 v2.6.3 中添加

PipeableTraverse2 (interface)
PipeableTraverse2(接口)

Signature 签名

export interface PipeableTraverse2<T extends URIS2> {
  <F extends URIS3>(F: Applicative3<F>): <A, FR, FE, B>(
    f: (a: A) => Kind3<F, FR, FE, B>
  ) => <TE>(ta: Kind2<T, TE, A>) => Kind3<F, FR, FE, Kind2<T, TE, B>>
  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(
    f: (a: A) => Kind2<F, FE, B>
  ) => <TE>(ta: Kind2<T, TE, A>) => Kind2<F, FE, Kind2<T, TE, B>>
  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(
    f: (a: A) => Kind2<F, FE, B>
  ) => <TE>(ta: Kind2<T, TE, A>) => Kind2<F, FE, Kind2<T, TE, B>>
  <F extends URIS>(F: Applicative1<F>): <A, B>(
    f: (a: A) => Kind<F, B>
  ) => <TE>(ta: Kind2<T, TE, A>) => Kind<F, Kind2<T, TE, B>>
  <F>(F: Applicative<F>): <A, B>(f: (a: A) => HKT<F, B>) => <TE>(ta: Kind2<T, TE, A>) => HKT<F, Kind2<T, TE, B>>
}

Added in v2.6.3 v2.6.3 中添加

Sequence (interface)   序列(接口)

Signature 签名

export interface Sequence<T> {
  <F extends URIS4>(F: Applicative4<F>): <S, R, E, A>(ta: HKT<T, Kind4<F, S, R, E, A>>) => Kind4<F, S, R, E, HKT<T, A>>
  <F extends URIS3>(F: Applicative3<F>): <R, E, A>(ta: HKT<T, Kind3<F, R, E, A>>) => Kind3<F, R, E, HKT<T, A>>
  <F extends URIS3, E>(F: Applicative3C<F, E>): <R, A>(ta: HKT<T, Kind3<F, R, E, A>>) => Kind3<F, R, E, HKT<T, A>>
  <F extends URIS2>(F: Applicative2<F>): <E, A>(ta: HKT<T, Kind2<F, E, A>>) => Kind2<F, E, HKT<T, A>>
  <F extends URIS2, E>(F: Applicative2C<F, E>): <A>(ta: HKT<T, Kind2<F, E, A>>) => Kind2<F, E, HKT<T, A>>
  <F extends URIS>(F: Applicative1<F>): <A>(ta: HKT<T, Kind<F, A>>) => Kind<F, HKT<T, A>>
  <F>(F: Applicative<F>): <A>(ta: HKT<T, HKT<F, A>>) => HKT<F, HKT<T, A>>
}

Added in v2.0.0 v2.0.0 中添加

Sequence1 (interface)   序列1(接口)

Signature 签名

export interface Sequence1<T extends URIS> {
  <F extends URIS4>(F: Applicative4<F>): <S, R, E, A>(
    ta: Kind<T, Kind4<F, S, R, E, A>>
  ) => Kind4<F, S, R, E, Kind<T, A>>
  <F extends URIS3>(F: Applicative3<F>): <R, E, A>(ta: Kind<T, Kind3<F, R, E, A>>) => Kind3<F, R, E, Kind<T, A>>
  <F extends URIS3, E>(F: Applicative3C<F, E>): <R, A>(ta: Kind<T, Kind3<F, R, E, A>>) => Kind3<F, R, E, Kind<T, A>>
  <F extends URIS2>(F: Applicative2<F>): <E, A>(ta: Kind<T, Kind2<F, E, A>>) => Kind2<F, E, Kind<T, A>>
  <F extends URIS2, E>(F: Applicative2C<F, E>): <A>(ta: Kind<T, Kind2<F, E, A>>) => Kind2<F, E, Kind<T, A>>
  <F extends URIS>(F: Applicative1<F>): <A>(ta: Kind<T, Kind<F, A>>) => Kind<F, Kind<T, A>>
  <F>(F: Applicative<F>): <A>(ta: Kind<T, HKT<F, A>>) => HKT<F, Kind<T, A>>
}

Added in v2.0.0 v2.0.0 中添加

Sequence2 (interface)   序列2(接口)

Signature 签名

export interface Sequence2<T extends URIS2> {
  <F extends URIS4>(F: Applicative4<F>): <TE, S, R, FE, A>(
    ta: Kind2<T, TE, Kind4<F, S, R, FE, A>>
  ) => Kind4<F, S, R, FE, Kind2<T, TE, A>>
  <F extends URIS3>(F: Applicative3<F>): <TE, R, FE, A>(
    ta: Kind2<T, TE, Kind3<F, R, FE, A>>
  ) => Kind3<F, R, FE, Kind2<T, TE, A>>
  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <TE, R, A>(
    ta: Kind2<T, TE, Kind3<F, R, FE, A>>
  ) => Kind3<F, R, FE, Kind2<T, TE, A>>
  <F extends URIS2>(F: Applicative2<F>): <TE, FE, A>(ta: Kind2<T, TE, Kind2<F, FE, A>>) => Kind2<F, FE, Kind2<T, TE, A>>
  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <TE, A>(
    ta: Kind2<T, TE, Kind2<F, FE, A>>
  ) => Kind2<F, FE, Kind2<T, TE, A>>
  <F extends URIS>(F: Applicative1<F>): <E, A>(ta: Kind2<T, E, Kind<F, A>>) => Kind<F, Kind2<T, E, A>>
  <F>(F: Applicative<F>): <E, A>(ta: Kind2<T, E, HKT<F, A>>) => HKT<F, Kind2<T, E, A>>
}

Added in v2.0.0 v2.0.0 中添加

Sequence2C (interface)   序列2C(接口)

Signature 签名

export interface Sequence2C<T extends URIS2, E> {
  <F extends URIS4>(F: Applicative4<F>): <S, R, FE, A>(
    ta: Kind2<T, E, Kind4<F, S, R, FE, A>>
  ) => Kind4<F, S, R, FE, Kind2<T, E, A>>
  <F extends URIS3>(F: Applicative3<F>): <R, FE, A>(
    ta: Kind2<T, E, Kind3<F, R, FE, A>>
  ) => Kind3<F, R, FE, Kind2<T, E, A>>
  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <R, A>(
    ta: Kind2<T, E, Kind3<F, R, FE, A>>
  ) => Kind3<F, R, FE, Kind2<T, E, A>>
  <F extends URIS2>(F: Applicative2<F>): <FE, A>(ta: Kind2<T, E, Kind2<F, FE, A>>) => Kind2<F, FE, Kind2<T, E, A>>
  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A>(ta: Kind2<T, E, Kind2<F, FE, A>>) => Kind2<F, FE, Kind2<T, E, A>>
  <F extends URIS>(F: Applicative1<F>): <A>(ta: Kind2<T, E, Kind<F, A>>) => Kind<F, Kind2<T, E, A>>
  <F>(F: Applicative<F>): <A>(ta: Kind2<T, E, HKT<F, A>>) => HKT<F, Kind2<T, E, A>>
}

Added in v2.0.0 v2.0.0 中添加

Sequence3 (interface)   序列3(接口)

Signature 签名

export interface Sequence3<T extends URIS3> {
  <F extends URIS4>(F: Applicative4<F>): <TR, TE, S, FR, FE, A>(
    ta: Kind3<T, TR, TE, Kind4<F, S, FR, FE, A>>
  ) => Kind4<F, S, FR, FE, Kind3<T, TR, TE, A>>
  <F extends URIS3>(F: Applicative3<F>): <TR, TE, FR, FE, A>(
    ta: Kind3<T, TR, TE, Kind3<F, FR, FE, A>>
  ) => Kind3<F, FR, FE, Kind3<T, TR, TE, A>>
  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <TR, TE, FR, A>(
    ta: Kind3<T, TR, TE, Kind3<F, FR, FE, A>>
  ) => Kind3<F, FR, FE, Kind3<T, TR, TE, A>>
  <F extends URIS2>(F: Applicative2<F>): <R, TE, FE, A>(
    ta: Kind3<T, R, TE, Kind2<F, FE, A>>
  ) => Kind2<F, FE, Kind3<T, R, TE, A>>
  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <R, TE, A>(
    ta: Kind3<T, R, TE, Kind2<F, FE, A>>
  ) => Kind2<F, FE, Kind3<T, R, TE, A>>
  <F extends URIS>(F: Applicative1<F>): <R, E, A>(ta: Kind3<T, R, E, Kind<F, A>>) => Kind<F, Kind3<T, R, E, A>>
  <F>(F: Applicative<F>): <R, E, A>(ta: Kind3<T, R, E, HKT<F, A>>) => HKT<F, Kind3<T, R, E, A>>
}

Added in v2.0.0 v2.0.0 中添加

Traverse (interface)   遍历(接口)

Signature 签名

export interface Traverse<T> {
  <F extends URIS4>(F: Applicative4<F>): <A, S, R, E, B>(
    ta: HKT<T, A>,
    f: (a: A) => Kind4<F, S, R, E, B>
  ) => Kind4<F, S, R, E, HKT<T, B>>
  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(
    ta: HKT<T, A>,
    f: (a: A) => Kind3<F, R, E, B>
  ) => Kind3<F, R, E, HKT<T, B>>
  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(
    ta: HKT<T, A>,
    f: (a: A) => Kind3<F, R, E, B>
  ) => Kind3<F, R, E, HKT<T, B>>
  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(ta: HKT<T, A>, f: (a: A) => Kind2<F, E, B>) => Kind2<F, E, HKT<T, B>>
  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(
    ta: HKT<T, A>,
    f: (a: A) => Kind2<F, E, B>
  ) => Kind2<F, E, HKT<T, B>>
  <F extends URIS>(F: Applicative1<F>): <A, B>(ta: HKT<T, A>, f: (a: A) => Kind<F, B>) => Kind<F, HKT<T, B>>
  <F>(F: Applicative<F>): <A, B>(ta: HKT<T, A>, f: (a: A) => HKT<F, B>) => HKT<F, HKT<T, B>>
}

Added in v2.0.0 v2.0.0 中添加

Traverse1 (interface)   遍历1(接口)

Signature 签名

export interface Traverse1<T extends URIS> {
  <F extends URIS4>(F: Applicative4<F>): <A, S, R, E, B>(
    ta: Kind<T, A>,
    f: (a: A) => Kind4<F, S, R, E, B>
  ) => Kind4<F, S, R, E, Kind<T, B>>
  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(
    ta: Kind<T, A>,
    f: (a: A) => Kind3<F, R, E, B>
  ) => Kind3<F, R, E, Kind<T, B>>
  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(
    ta: Kind<T, A>,
    f: (a: A) => Kind3<F, R, E, B>
  ) => Kind3<F, R, E, Kind<T, B>>
  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(
    ta: Kind<T, A>,
    f: (a: A) => Kind2<F, E, B>
  ) => Kind2<F, E, Kind<T, B>>
  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(
    ta: Kind<T, A>,
    f: (a: A) => Kind2<F, E, B>
  ) => Kind2<F, E, Kind<T, B>>
  <F extends URIS>(F: Applicative1<F>): <A, B>(ta: Kind<T, A>, f: (a: A) => Kind<F, B>) => Kind<F, Kind<T, B>>
  <F>(F: Applicative<F>): <A, B>(ta: Kind<T, A>, f: (a: A) => HKT<F, B>) => HKT<F, Kind<T, B>>
}

Added in v2.0.0 v2.0.0 中添加

Traverse2 (interface)   遍历2(接口)

Signature 签名

export interface Traverse2<T extends URIS2> {
  <F extends URIS4>(F: Applicative4<F>): <TE, A, S, R, FE, B>(
    ta: Kind2<T, TE, A>,
    f: (a: A) => Kind4<F, S, R, FE, B>
  ) => Kind4<F, S, R, FE, Kind2<T, TE, B>>
  <F extends URIS3>(F: Applicative3<F>): <TE, A, R, FE, B>(
    ta: Kind2<T, TE, A>,
    f: (a: A) => Kind3<F, R, FE, B>
  ) => Kind3<F, R, FE, Kind2<T, TE, B>>
  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <TE, A, R, B>(
    ta: Kind2<T, TE, A>,
    f: (a: A) => Kind3<F, R, FE, B>
  ) => Kind3<F, R, FE, Kind2<T, TE, B>>
  <F extends URIS2>(F: Applicative2<F>): <TE, A, FE, B>(
    ta: Kind2<T, TE, A>,
    f: (a: A) => Kind2<F, FE, B>
  ) => Kind2<F, FE, Kind2<T, TE, B>>
  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <TE, A, B>(
    ta: Kind2<T, TE, A>,
    f: (a: A) => Kind2<F, FE, B>
  ) => Kind2<F, FE, Kind2<T, TE, B>>
  <F extends URIS>(F: Applicative1<F>): <E, A, B>(
    ta: Kind2<T, E, A>,
    f: (a: A) => Kind<F, B>
  ) => Kind<F, Kind2<T, E, B>>
  <F>(F: Applicative<F>): <E, A, B>(ta: Kind2<T, E, A>, f: (a: A) => HKT<F, B>) => HKT<F, Kind2<T, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

Traverse2C (interface)   Traverse2C(接口)

Signature 签名

export interface Traverse2C<T extends URIS2, E> {
  <F extends URIS4>(F: Applicative4<F>): <A, S, R, FE, B>(
    ta: Kind2<T, E, A>,
    f: (a: A) => Kind4<F, S, R, FE, B>
  ) => Kind4<F, S, R, FE, Kind2<T, E, B>>
  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B>(
    ta: Kind2<T, E, A>,
    f: (a: A) => Kind3<F, R, FE, B>
  ) => Kind3<F, R, FE, Kind2<T, E, B>>
  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <A, R, B>(
    ta: Kind2<T, E, A>,
    f: (a: A) => Kind3<F, R, FE, B>
  ) => Kind3<F, R, FE, Kind2<T, E, B>>
  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(
    ta: Kind2<T, E, A>,
    f: (a: A) => Kind2<F, FE, B>
  ) => Kind2<F, FE, Kind2<T, E, B>>
  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(
    ta: Kind2<T, E, A>,
    f: (a: A) => Kind2<F, FE, B>
  ) => Kind2<F, FE, Kind2<T, E, B>>
  <F extends URIS>(F: Applicative1<F>): <A, B>(ta: Kind2<T, E, A>, f: (a: A) => Kind<F, B>) => Kind<F, Kind2<T, E, B>>
  <F>(F: Applicative<F>): <A, B>(ta: Kind2<T, E, A>, f: (a: A) => HKT<F, B>) => HKT<F, Kind2<T, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

Traverse3 (interface)   遍历3(接口)

Signature 签名

export interface Traverse3<T extends URIS3> {
  <F extends URIS4>(F: Applicative4<F>): <TR, TE, A, S, FR, FE, B>(
    ta: Kind3<T, TR, TE, A>,
    f: (a: A) => Kind4<F, S, FR, FE, B>
  ) => Kind4<F, S, FR, FE, Kind3<T, TR, TE, B>>
  <F extends URIS3>(F: Applicative3<F>): <TR, TE, A, FR, FE, B>(
    ta: Kind3<T, TR, TE, A>,
    f: (a: A) => Kind3<F, FR, FE, B>
  ) => Kind3<F, FR, FE, Kind3<T, TR, TE, B>>
  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <TR, TE, A, FR, B>(
    ta: Kind3<T, TR, TE, A>,
    f: (a: A) => Kind3<F, FR, FE, B>
  ) => Kind3<F, FR, FE, Kind3<T, TR, TE, B>>
  <F extends URIS2>(F: Applicative2<F>): <TR, A, TE, FE, B>(
    ta: Kind3<T, TR, TE, A>,
    f: (a: A) => Kind2<F, FE, B>
  ) => Kind2<F, FE, Kind3<T, TR, TE, B>>
  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <R, TE, A, B>(
    ta: Kind3<T, R, TE, A>,
    f: (a: A) => Kind2<F, FE, B>
  ) => Kind2<F, FE, Kind3<T, R, TE, B>>
  <F extends URIS>(F: Applicative1<F>): <R, E, A, B>(
    ta: Kind3<T, R, E, A>,
    f: (a: A) => Kind<F, B>
  ) => Kind<F, Kind3<T, R, E, B>>
  <F>(F: Applicative<F>): <R, E, A, B>(ta: Kind3<T, R, E, A>, f: (a: A) => HKT<F, B>) => HKT<F, Kind3<T, R, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

sequence   顺序

sequence composition.

Signature 签名

export declare function sequence<T extends URIS, G extends URIS2>(
  T: Traversable1<T>,
  G: Traversable2<G>
): {
  <F extends URIS4>(F: Applicative4<F>): <GE, S, R, FE, A>(
    tgfa: Kind<T, Kind2<G, GE, Kind4<F, S, R, FE, A>>>
  ) => Kind4<F, S, R, FE, Kind<T, Kind2<G, GE, A>>>
  <F extends URIS3>(F: Applicative3<F>): <GE, R, FE, A>(
    tgfa: Kind<T, Kind2<G, GE, Kind3<F, R, FE, A>>>
  ) => Kind3<F, R, FE, Kind<T, Kind2<G, GE, A>>>
  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <GE, R, A>(
    tgfa: Kind<T, Kind2<G, GE, Kind3<F, R, FE, A>>>
  ) => Kind3<F, R, FE, Kind<T, Kind2<G, GE, A>>>
  <F extends URIS2>(F: Applicative2<F>): <GE, FE, A>(
    tgfa: Kind<T, Kind2<G, GE, Kind2<F, FE, A>>>
  ) => Kind2<F, FE, Kind<T, Kind2<G, GE, A>>>
  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <GE, A>(
    tgfa: Kind<T, Kind2<G, GE, Kind2<F, FE, A>>>
  ) => Kind2<F, FE, Kind<T, Kind2<G, GE, A>>>
  <F extends URIS>(F: Applicative1<F>): <GE, A>(
    tgfa: Kind<T, Kind2<G, GE, Kind<F, A>>>
  ) => Kind<F, Kind<T, Kind2<G, GE, A>>>
  <F>(F: Applicative<F>): <A>(tgfa: HKT<T, HKT<G, HKT<F, A>>>) => HKT<F, HKT<T, HKT<G, A>>>
}
export declare function sequence<T extends URIS, G extends URIS>(
  T: Traversable1<T>,
  G: Traversable1<G>
): {
  <F extends URIS4>(F: Applicative4<F>): <S, R, E, A>(
    tgfa: Kind<T, Kind<G, Kind4<F, S, R, E, A>>>
  ) => Kind4<F, S, R, E, Kind<T, Kind<G, A>>>
  <F extends URIS3>(F: Applicative3<F>): <R, E, A>(
    tgfa: Kind<T, Kind<G, Kind3<F, R, E, A>>>
  ) => Kind3<F, R, E, Kind<T, Kind<G, A>>>
  <F extends URIS3, E>(F: Applicative3C<F, E>): <R, A>(
    tgfa: Kind<T, Kind<G, Kind3<F, R, E, A>>>
  ) => Kind3<F, R, E, Kind<T, Kind<G, A>>>
  <F extends URIS2>(F: Applicative2<F>): <E, A>(
    tgfa: Kind<T, Kind<G, Kind2<F, E, A>>>
  ) => Kind2<F, E, Kind<T, Kind<G, A>>>
  <F extends URIS2, E>(F: Applicative2C<F, E>): <A>(
    tgfa: Kind<T, Kind<G, Kind2<F, E, A>>>
  ) => Kind2<F, E, Kind<T, Kind<G, A>>>
  <F extends URIS>(F: Applicative1<F>): <A>(tgfa: Kind<T, Kind<G, Kind<F, A>>>) => Kind<F, Kind<T, Kind<G, A>>>
  <F>(F: Applicative<F>): <A>(tgfa: HKT<T, HKT<G, HKT<F, A>>>) => HKT<F, HKT<T, HKT<G, A>>>
}
export declare function sequence<T, G>(
  T: Traversable<T>,
  G: Traversable<G>
): <F>(F: Applicative<F>) => <A>(tgfa: HKT<T, HKT<G, HKT<F, A>>>) => HKT<F, HKT<T, HKT<G, A>>>

Added in v2.10.0 v2.10.0 中添加

traverse   遍历

traverse composition.

Signature 签名

export declare function traverse<T extends URIS, G extends URIS2>(
  T: Traversable1<T>,
  G: Traversable2<G>
): {
  <F extends URIS4>(F: Applicative4<F>): <A, S, R, FE, B>(
    f: (a: A) => Kind4<F, S, R, FE, B>
  ) => <GE>(tga: Kind<T, Kind2<G, GE, A>>) => Kind4<F, S, R, FE, Kind<T, Kind2<G, GE, B>>>
  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B>(
    f: (a: A) => Kind3<F, R, FE, B>
  ) => <GE>(tga: Kind<T, Kind2<G, GE, A>>) => Kind3<F, R, FE, Kind<T, Kind2<G, GE, B>>>
  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <A, R, B>(
    f: (a: A) => Kind3<F, R, FE, B>
  ) => <GE>(tga: Kind<T, Kind2<G, GE, A>>) => Kind3<F, R, FE, Kind<T, Kind2<G, GE, B>>>
  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(
    f: (a: A) => Kind2<F, FE, B>
  ) => <GE>(tga: Kind<T, Kind2<G, GE, A>>) => Kind2<F, FE, Kind<T, Kind2<G, GE, B>>>
  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(
    f: (a: A) => Kind2<F, FE, B>
  ) => <GE>(tga: Kind<T, Kind2<G, GE, A>>) => Kind2<F, FE, Kind<T, Kind2<G, GE, B>>>
  <F extends URIS>(F: Applicative1<F>): <A, B>(
    f: (a: A) => Kind<F, B>
  ) => <GE>(tga: Kind<T, Kind2<G, GE, A>>) => Kind<F, Kind<T, Kind2<G, GE, B>>>
  <F>(F: Applicative<F>): <A, B>(
    f: (a: A) => HKT<F, B>
  ) => <GE>(tga: Kind<T, Kind2<G, GE, A>>) => HKT<F, Kind<T, Kind2<G, GE, B>>>
}
export declare function traverse<T extends URIS, G extends URIS>(
  T: Traversable1<T>,
  G: Traversable1<G>
): {
  <F extends URIS4>(F: Applicative4<F>): <A, S, R, E, B>(
    f: (a: A) => Kind4<F, S, R, E, B>
  ) => (tga: Kind<T, Kind<G, A>>) => Kind4<F, S, R, E, Kind<T, Kind<G, B>>>
  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(
    f: (a: A) => Kind3<F, R, E, B>
  ) => (tga: Kind<T, Kind<G, A>>) => Kind3<F, R, E, Kind<T, Kind<G, B>>>
  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(
    f: (a: A) => Kind3<F, R, E, B>
  ) => (tga: Kind<T, Kind<G, A>>) => Kind3<F, R, E, Kind<T, Kind<G, B>>>
  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(
    f: (a: A) => Kind2<F, E, B>
  ) => (tga: Kind<T, Kind<G, A>>) => Kind2<F, E, Kind<T, Kind<G, B>>>
  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(
    f: (a: A) => Kind2<F, E, B>
  ) => (tga: Kind<T, Kind<G, A>>) => Kind2<F, E, Kind<T, Kind<G, B>>>
  <F extends URIS>(F: Applicative1<F>): <A, B>(
    f: (a: A) => Kind<F, B>
  ) => (tga: Kind<T, Kind<G, A>>) => Kind<F, Kind<T, Kind<G, B>>>
  <F>(F: Applicative<F>): <A, B>(f: (a: A) => HKT<F, B>) => (tga: Kind<T, Kind<G, A>>) => HKT<F, Kind<T, Kind<G, B>>>
}
export declare function traverse<T, G>(
  T: Traversable<T>,
  G: Traversable<G>
): <F>(F: Applicative<F>) => <A, B>(f: (a: A) => HKT<F, B>) => (tga: HKT<T, HKT<G, A>>) => HKT<F, HKT<T, HKT<G, B>>>

Added in v2.10.0 v2.10.0 中添加

zone of death
死亡地带

SequenceComposition11 序列组合11 (interface)   (界面)

Signature 签名

export interface SequenceComposition11<F extends URIS, G extends URIS> {
  <H extends URIS3>(H: Applicative3<H>): <R, E, A>(
    fga: Kind<F, Kind<G, Kind3<H, R, E, A>>>
  ) => Kind3<H, R, E, Kind<F, Kind<G, A>>>
  <H extends URIS2>(H: Applicative2<H>): <E, A>(
    fga: Kind<F, Kind<G, Kind2<H, E, A>>>
  ) => Kind2<H, E, Kind<F, Kind<G, A>>>
  <H extends URIS2, E>(H: Applicative2C<H, E>): <A>(
    fga: Kind<F, Kind<G, Kind2<H, E, A>>>
  ) => Kind2<H, E, Kind<F, Kind<G, A>>>
  <H extends URIS>(H: Applicative1<H>): <A>(fga: Kind<F, Kind<G, Kind<H, A>>>) => Kind<H, Kind<F, Kind<G, A>>>
  <H>(H: Applicative<H>): <A>(fga: Kind<F, Kind<G, HKT<H, A>>>) => HKT<H, Kind<F, Kind<G, A>>>
}

Added in v2.0.0 v2.0.0 中添加

TraversableComposition11
可遍历组合11
(interface)   (界面)

Signature 签名

export interface TraversableComposition11<F extends URIS, G extends URIS>
  extends FoldableComposition11<F, G>,
    FunctorComposition11<F, G> {
  readonly traverse: TraverseComposition11<F, G>
  readonly sequence: SequenceComposition11<F, G>
}

Added in v2.0.0 v2.0.0 中添加

TraversableComposition 可遍历组合 (interface)   (界面)

Signature 签名

export interface TraversableComposition<F, G> extends FoldableComposition<F, G>, FunctorComposition<F, G> {
  readonly traverse: <H>(
    H: Applicative<H>
  ) => <A, B>(fga: HKT<F, HKT<G, A>>, f: (a: A) => HKT<H, B>) => HKT<H, HKT<F, HKT<G, B>>>
  readonly sequence: <H>(H: Applicative<H>) => <A>(fga: HKT<F, HKT<G, HKT<H, A>>>) => HKT<H, HKT<F, HKT<G, A>>>
}

Added in v2.0.0 v2.0.0 中添加

TraverseComposition11 遍历构图11 (interface)   (界面)

Signature 签名

export interface TraverseComposition11<F extends URIS, G extends URIS> {
  <H extends URIS3>(H: Applicative3<H>): <R, E, A, B>(
    fga: Kind<F, Kind<G, A>>,
    f: (a: A) => Kind3<H, R, E, B>
  ) => Kind3<H, R, E, Kind<F, Kind<G, B>>>
  <H extends URIS2>(H: Applicative2<H>): <E, A, B>(
    fga: Kind<F, Kind<G, A>>,
    f: (a: A) => Kind2<H, E, B>
  ) => Kind2<H, E, Kind<F, Kind<G, B>>>
  <H extends URIS2, E>(H: Applicative2C<H, E>): <A, B>(
    fga: Kind<F, Kind<G, A>>,
    f: (a: A) => Kind2<H, E, B>
  ) => Kind2<H, E, Kind<F, Kind<G, B>>>
  <H extends URIS>(H: Applicative1<H>): <A, B>(
    fga: Kind<F, Kind<G, A>>,
    f: (a: A) => Kind<H, B>
  ) => Kind<H, Kind<F, Kind<G, B>>>
  <H>(H: Applicative<H>): <A, B>(fga: Kind<F, Kind<G, A>>, f: (a: A) => HKT<H, B>) => HKT<H, Kind<F, Kind<G, B>>>
}

Added in v2.0.0 v2.0.0 中添加

getTraversableComposition
获取可遍历组合

Use 使用

instead.

Signature 签名

export declare function getTraversableComposition<F extends URIS, G extends URIS>(
  F: Traversable1<F>,
  G: Traversable1<G>
): TraversableComposition11<F, G>
export declare function getTraversableComposition<F, G>(
  F: Traversable<F>,
  G: Traversable<G>
): TraversableComposition<F, G>

Added in v2.0.0 v2.0.0 中添加

TraversableWithIndex overview
TraversableWithIndex 概述

A Traversable with an additional index. A TraversableWithIndex instance must be compatible with its Traversable instance
带有附加索引的 TraversableTraversableWithIndex 实例必须与其 Traversable 实例兼容

traverse(F)(ta, f) = traverseWithIndex(F)(ta, (_, a) => f(a))

with its FoldableWithIndex instance 及其 FoldableWithIndex 实例

foldMapWithIndex(M)(ta, f) = traverseWithIndex(getApplicative(M))(ta, (i, a) => new Const(f(i, a))).value

and with its FunctorWithIndex instance
及其 FunctorWithIndex 实例

mapWithIndex(ta, f) = traverseWithIndex(identity)(ta, (i, a) => new Identity(f(i, a))).value

Added in v2.0.0  v2.0.0 中添加


Table of contents
目录


utils   实用程序

PipeableTraverseWithIndex1 (interface)
PipeableTraverseWithIndex1(接口)

Signature 签名

export interface PipeableTraverseWithIndex1<T extends URIS, I> {
  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(
    f: (i: I, a: A) => Kind3<F, R, E, B>
  ) => (ta: Kind<T, A>) => Kind3<F, R, E, Kind<T, B>>
  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(
    f: (i: I, a: A) => Kind3<F, R, E, B>
  ) => (ta: Kind<T, A>) => Kind3<F, R, E, Kind<T, B>>
  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(
    f: (i: I, a: A) => Kind2<F, E, B>
  ) => (ta: Kind<T, A>) => Kind2<F, E, Kind<T, B>>
  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(
    f: (i: I, a: A) => Kind2<F, E, B>
  ) => (ta: Kind<T, A>) => Kind2<F, E, Kind<T, B>>
  <F extends URIS>(F: Applicative1<F>): <A, B>(f: (i: I, a: A) => Kind<F, B>) => (ta: Kind<T, A>) => Kind<F, Kind<T, B>>
  <F>(F: Applicative<F>): <A, B>(f: (i: I, a: A) => HKT<F, B>) => (ta: Kind<T, A>) => HKT<F, Kind<T, B>>
}

Added in v2.6.3 v2.6.3 中添加

PipeableTraverseWithIndex2 (interface)
PipeableTraverseWithIndex2(接口)

Signature 签名

export interface PipeableTraverseWithIndex2<T extends URIS2, I> {
  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B>(
    f: (i: I, a: A) => Kind3<F, R, FE, B>
  ) => <TE>(ta: Kind2<T, TE, A>) => Kind3<F, R, FE, Kind2<T, TE, B>>
  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(
    f: (i: I, a: A) => Kind2<F, FE, B>
  ) => <TE>(ta: Kind2<T, TE, A>) => Kind2<F, FE, Kind2<T, TE, B>>
  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(
    f: (i: I, a: A) => Kind2<F, FE, B>
  ) => <TE>(ta: Kind2<T, TE, A>) => Kind2<F, FE, Kind2<T, TE, B>>
  <F extends URIS>(F: Applicative1<F>): <A, B>(
    f: (i: I, a: A) => Kind<F, B>
  ) => <E>(ta: Kind2<T, E, A>) => Kind<F, Kind2<T, E, B>>
  <F>(F: Applicative<F>): <A, B>(f: (i: I, a: A) => HKT<F, B>) => <E>(ta: Kind2<T, E, A>) => HKT<F, Kind2<T, E, B>>
}

Added in v2.6.3 v2.6.3 中添加

TraversableWithIndex (interface)
可遍历带索引(接口)

Signature 签名

export interface TraversableWithIndex<T, I> extends FunctorWithIndex<T, I>, FoldableWithIndex<T, I>, Traversable<T> {
  readonly traverseWithIndex: TraverseWithIndex<T, I>
}

Added in v2.0.0 v2.0.0 中添加

TraversableWithIndex1 (interface)
TraversableWithIndex1(接口)

Signature 签名

export interface TraversableWithIndex1<T extends URIS, I>
  extends FunctorWithIndex1<T, I>,
    FoldableWithIndex1<T, I>,
    Traversable1<T> {
  readonly traverseWithIndex: TraverseWithIndex1<T, I>
}

Added in v2.0.0 v2.0.0 中添加

TraversableWithIndex2 (interface)
TraversableWithIndex2(接口)

Signature 签名

export interface TraversableWithIndex2<T extends URIS2, I>
  extends FunctorWithIndex2<T, I>,
    FoldableWithIndex2<T, I>,
    Traversable2<T> {
  readonly traverseWithIndex: TraverseWithIndex2<T, I>
}

Added in v2.0.0 v2.0.0 中添加

TraversableWithIndex2C (interface)
TraversableWithIndex2C(接口)

Signature 签名

export interface TraversableWithIndex2C<T extends URIS2, I, E>
  extends FunctorWithIndex2C<T, I, E>,
    FoldableWithIndex2C<T, I, E>,
    Traversable2C<T, E> {
  readonly traverseWithIndex: TraverseWithIndex2C<T, I, E>
}

Added in v2.0.0 v2.0.0 中添加

TraverseWithIndex (interface)
带索引遍历(接口)

Signature 签名

export interface TraverseWithIndex<T, I> {
  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(
    ta: HKT<T, A>,
    f: (i: I, a: A) => Kind3<F, R, E, B>
  ) => Kind3<F, R, E, HKT<T, B>>
  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(
    ta: HKT<T, A>,
    f: (i: I, a: A) => Kind3<F, R, E, B>
  ) => Kind3<F, R, E, HKT<T, B>>
  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(
    ta: HKT<T, A>,
    f: (i: I, a: A) => Kind2<F, E, B>
  ) => Kind2<F, E, HKT<T, B>>
  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(
    ta: HKT<T, A>,
    f: (i: I, a: A) => Kind2<F, E, B>
  ) => Kind2<F, E, HKT<T, B>>
  <F extends URIS>(F: Applicative1<F>): <A, B>(ta: HKT<T, A>, f: (i: I, a: A) => Kind<F, B>) => Kind<F, HKT<T, B>>
  <F>(F: Applicative<F>): <A, B>(ta: HKT<T, A>, f: (i: I, a: A) => HKT<F, B>) => HKT<F, HKT<T, B>>
}

Added in v2.0.0 v2.0.0 中添加

TraverseWithIndex1 (interface)
TraverseWithIndex1(接口)

Signature 签名

export interface TraverseWithIndex1<T extends URIS, I> {
  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(
    ta: Kind<T, A>,
    f: (i: I, a: A) => Kind3<F, R, E, B>
  ) => Kind3<F, R, E, Kind<T, B>>
  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(
    ta: Kind<T, A>,
    f: (i: I, a: A) => Kind3<F, R, E, B>
  ) => Kind3<F, R, E, Kind<T, B>>
  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(
    ta: Kind<T, A>,
    f: (i: I, a: A) => Kind2<F, E, B>
  ) => Kind2<F, E, Kind<T, B>>
  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(
    ta: Kind<T, A>,
    f: (i: I, a: A) => Kind2<F, E, B>
  ) => Kind2<F, E, Kind<T, B>>
  <F extends URIS>(F: Applicative1<F>): <A, B>(ta: Kind<T, A>, f: (i: I, a: A) => Kind<F, B>) => Kind<F, Kind<T, B>>
  <F>(F: Applicative<F>): <A, B>(ta: Kind<T, A>, f: (i: I, a: A) => HKT<F, B>) => HKT<F, Kind<T, B>>
}

Added in v2.0.0 v2.0.0 中添加

TraverseWithIndex2 (interface)
TraverseWithIndex2(接口)

Signature 签名

export interface TraverseWithIndex2<T extends URIS2, I> {
  <F extends URIS3>(F: Applicative3<F>): <TE, A, R, FE, B>(
    ta: Kind2<T, TE, A>,
    f: (i: I, a: A) => Kind3<F, R, FE, B>
  ) => Kind3<F, R, FE, Kind2<T, TE, B>>
  <F extends URIS2>(F: Applicative2<F>): <TE, A, FE, B>(
    ta: Kind2<T, TE, A>,
    f: (i: I, a: A) => Kind2<F, FE, B>
  ) => Kind2<F, FE, Kind2<T, TE, B>>
  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <TE, A, B>(
    ta: Kind2<T, TE, A>,
    f: (i: I, a: A) => Kind2<F, FE, B>
  ) => Kind2<F, FE, Kind2<T, TE, B>>
  <F extends URIS>(F: Applicative1<F>): <E, A, B>(
    ta: Kind2<T, E, A>,
    f: (i: I, a: A) => Kind<F, B>
  ) => Kind<F, Kind2<T, E, B>>
  <F>(F: Applicative<F>): <E, A, B>(ta: Kind2<T, E, A>, f: (i: I, a: A) => HKT<F, B>) => HKT<F, Kind2<T, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

TraverseWithIndex2C (interface)
TraverseWithIndex2C(接口)

Signature 签名

export interface TraverseWithIndex2C<T extends URIS2, I, E> {
  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B>(
    ta: Kind2<T, E, A>,
    f: (i: I, a: A) => Kind3<F, R, FE, B>
  ) => Kind3<F, R, FE, Kind2<T, E, B>>
  <F extends URIS3>(F: Applicative3C<F, E>): <A, R, B>(
    ta: Kind2<T, E, A>,
    f: (i: I, a: A) => Kind3<F, R, E, B>
  ) => Kind3<F, R, E, Kind2<T, E, B>>
  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(
    ta: Kind2<T, E, A>,
    f: (i: I, a: A) => Kind2<F, FE, B>
  ) => Kind2<F, FE, Kind2<T, E, B>>
  <F extends URIS2>(F: Applicative2C<F, E>): <A, B>(
    ta: Kind2<T, E, A>,
    f: (i: I, a: A) => Kind2<F, E, B>
  ) => Kind2<F, E, Kind2<T, E, B>>
  <F extends URIS>(F: Applicative1<F>): <A, B>(
    ta: Kind2<T, E, A>,
    f: (i: I, a: A) => Kind<F, B>
  ) => Kind<F, Kind2<T, E, B>>
  <F>(F: Applicative<F>): <A, B>(ta: Kind2<T, E, A>, f: (i: I, a: A) => HKT<F, B>) => HKT<F, Kind2<T, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

Tree overview  树概述

Multi-way trees (aka rose trees) and forests, where a forest is
多路树(又名玫瑰树)和森林,森林所在的地方

type Forest<A> = Array<Tree<A>>

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


Extract   提炼

extract   提炼

Signature 签名

export declare const extract: <A>(wa: Tree<A>) => A

Added in v2.6.2 v2.6.2 中添加

constructors  构造函数

make   制作

Signature 签名

export declare function make<A>(value: A, forest: Forest<A> = []): Tree<A>

Added in v2.0.0 v2.0.0 中添加

of  

Signature 签名

export declare const of: <A>(a: A) => Tree<A>

Added in v2.7.0 v2.7.0 中添加

unfoldForest   展开森林

Build a (possibly infinite) forest from a list of seed values in breadth-first order.
根据广度优先顺序的种子值列表构建一个(可能是无限的)森林。

Signature 签名

export declare function unfoldForest<A, B>(bs: Array<B>, f: (b: B) => [A, Array<B>]): Forest<A>

Added in v2.0.0 v2.0.0 中添加

unfoldForestM   展开森林M

Monadic forest builder, in depth-first order
Monadic 森林构建器,按深度优先顺序

Signature 签名

export declare function unfoldForestM<M extends URIS4>(
  M: Monad4<M>
): <S, R, E, A, B>(bs: Array<B>, f: (b: B) => Kind4<M, S, R, E, [A, Array<B>]>) => Kind4<M, S, R, E, Forest<A>>
export declare function unfoldForestM<M extends URIS3>(
  M: Monad3<M>
): <R, E, A, B>(bs: Array<B>, f: (b: B) => Kind3<M, R, E, [A, Array<B>]>) => Kind3<M, R, E, Forest<A>>
export declare function unfoldForestM<M extends URIS3, E>(
  M: Monad3C<M, E>
): <R, A, B>(bs: Array<B>, f: (b: B) => Kind3<M, R, E, [A, Array<B>]>) => Kind3<M, R, E, Forest<A>>
export declare function unfoldForestM<M extends URIS2>(
  M: Monad2<M>
): <R, E, B>(bs: Array<B>, f: (b: B) => Kind2<M, R, [E, Array<B>]>) => Kind2<M, R, Forest<E>>
export declare function unfoldForestM<M extends URIS2, E>(
  M: Monad2C<M, E>
): <A, B>(bs: Array<B>, f: (b: B) => Kind2<M, E, [A, Array<B>]>) => Kind2<M, E, Forest<A>>
export declare function unfoldForestM<M extends URIS>(
  M: Monad1<M>
): <A, B>(bs: Array<B>, f: (b: B) => Kind<M, [A, Array<B>]>) => Kind<M, Forest<A>>
export declare function unfoldForestM<M>(
  M: MonadHKT<M>
): <A, B>(bs: Array<B>, f: (b: B) => HKT<M, [A, Array<B>]>) => HKT<M, Forest<A>>

Added in v2.0.0 v2.0.0 中添加

unfoldTree   展开树

Build a (possibly infinite) tree from a seed value in breadth-first order.
以广度优先顺序从种子值构建一棵(可能是无限的)树。

Signature 签名

export declare function unfoldTree<A, B>(b: B, f: (b: B) => [A, Array<B>]): Tree<A>

Added in v2.0.0 v2.0.0 中添加

unfoldTreeM   展开树M

Monadic tree builder, in depth-first order
Monadic 树构建器,按深度优先顺序

Signature 签名

export declare function unfoldTreeM<M extends URIS4>(
  M: Monad4<M>
): <S, R, E, A, B>(b: B, f: (b: B) => Kind4<M, S, R, E, [A, Array<B>]>) => Kind4<M, S, R, E, Tree<A>>
export declare function unfoldTreeM<M extends URIS3>(
  M: Monad3<M>
): <R, E, A, B>(b: B, f: (b: B) => Kind3<M, R, E, [A, Array<B>]>) => Kind3<M, R, E, Tree<A>>
export declare function unfoldTreeM<M extends URIS3, E>(
  M: Monad3C<M, E>
): <R, A, B>(b: B, f: (b: B) => Kind3<M, R, E, [A, Array<B>]>) => Kind3<M, R, E, Tree<A>>
export declare function unfoldTreeM<M extends URIS2>(
  M: Monad2<M>
): <E, A, B>(b: B, f: (b: B) => Kind2<M, E, [A, Array<B>]>) => Kind2<M, E, Tree<A>>
export declare function unfoldTreeM<M extends URIS2, E>(
  M: Monad2C<M, E>
): <A, B>(b: B, f: (b: B) => Kind2<M, E, [A, Array<B>]>) => Kind2<M, E, Tree<A>>
export declare function unfoldTreeM<M extends URIS>(
  M: Monad1<M>
): <A, B>(b: B, f: (b: B) => Kind<M, [A, Array<B>]>) => Kind<M, Tree<A>>
export declare function unfoldTreeM<M>(
  M: MonadHKT<M>
): <A, B>(b: B, f: (b: B) => HKT<M, [A, Array<B>]>) => HKT<M, Tree<A>>

Added in v2.0.0 v2.0.0 中添加

do notation   做记号

Do  

Signature 签名

export declare const Do: Tree<{}>

Added in v2.9.0 v2.9.0中添加

apS   apS

Signature 签名

export declare const apS: <N, A, B>(
  name: Exclude<N, keyof A>,
  fb: Tree<B>
) => (fa: Tree<A>) => Tree<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bind   绑定

Signature 签名

export declare const bind: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => Tree<B>
) => (ma: Tree<A>) => Tree<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0 v2.8.0 中添加

bindTo   绑定到

Signature 签名

export declare const bindTo: <N>(name: N) => <A>(fa: Tree<A>) => Tree<{ readonly [K in N]: A }>

Added in v2.8.0 v2.8.0 中添加

let  

Signature 签名

export declare const let: <N, A, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => B
) => (fa: Tree<A>) => Tree<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.13.0 v2.13.0 中添加

folding   折叠式的

fold   折叠

Fold a tree into a “summary” value in depth-first order.
按深度优先顺序将树折叠成“摘要”值。

For each node in the tree, apply f to the value and the result of applying f to each forest.
对于树中的每个节点,将 f 应用于 value ,并将 f 应用于每个 forest

This is also known as the catamorphism on trees.
这也称为树木的变态作用。

Signature 签名

export declare function fold<A, B>(f: (a: A, bs: Array<B>) => B): (tree: Tree<A>) => B

Example 例子

import { fold, make } from 'fp-ts/Tree'
import { concatAll } from 'fp-ts/Monoid'
import { MonoidSum } from 'fp-ts/number'

const t = make(1, [make(2), make(3)])

const sum = concatAll(MonoidSum)

// Sum the values in a tree:
assert.deepStrictEqual(fold((a: number, bs: Array<number>) => a + sum(bs))(t), 6)

// Find the maximum value in the tree:
assert.deepStrictEqual(fold((a: number, bs: Array<number>) => bs.reduce((b, acc) => Math.max(b, acc), a))(t), 3)

// Count the number of leaves in the tree:
assert.deepStrictEqual(fold((_: number, bs: Array<number>) => (bs.length === 0 ? 1 : sum(bs)))(t), 2)

Added in v2.6.0 v2.6.0 中添加

foldMap   折叠图

Signature 签名

export declare const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: Tree<A>) => M

Added in v2.0.0 v2.0.0 中添加

reduce   减少

Signature 签名

export declare const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: Tree<A>) => B

Added in v2.0.0 v2.0.0 中添加

reduceRight   减少右

Signature 签名

export declare const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: Tree<A>) => B

Added in v2.0.0 v2.0.0 中添加

instances   实例

Applicative   适用性

Signature 签名

export declare const Applicative: Applicative1<'Tree'>

Added in v2.7.0 v2.7.0 中添加

Apply   申请

Signature 签名

export declare const Apply: Apply1<'Tree'>

Added in v2.10.0 v2.10.0 中添加

Chain  

Signature 签名

export declare const Chain: Chain1<'Tree'>

Added in v2.10.0 v2.10.0 中添加

Comonad   科莫纳德

Signature 签名

export declare const Comonad: Comonad1<'Tree'>

Added in v2.7.0 v2.7.0 中添加

Foldable   折叠式

Signature 签名

export declare const Foldable: Foldable1<'Tree'>

Added in v2.7.0 v2.7.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor1<'Tree'>

Added in v2.7.0 v2.7.0 中添加

Monad   单子

Signature 签名

export declare const Monad: Monad1<'Tree'>

Added in v2.7.0 v2.7.0 中添加

Pointed  

Signature 签名

export declare const Pointed: Pointed1<'Tree'>

Added in v2.10.0 v2.10.0 中添加

Traversable   可穿越

Signature 签名

export declare const Traversable: Traversable1<'Tree'>

Added in v2.7.0 v2.7.0 中添加

getEq   得到方程

Signature 签名

export declare function getEq<A>(E: Eq<A>): Eq<Tree<A>>

Added in v2.0.0 v2.0.0 中添加

getShow   获取显示

Signature 签名

export declare function getShow<A>(S: Show<A>): Show<Tree<A>>

Added in v2.0.0 v2.0.0 中添加

legacy   遗产

chain  

Alias of flatMap.  flatMap 的别名。

Signature 签名

export declare const chain: <A, B>(f: (a: A) => Tree<B>) => (ma: Tree<A>) => Tree<B>

Added in v2.0.0 v2.0.0 中添加

mapping   映射

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <B>(fab: Tree<(a: A) => B>) => Tree<B>

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => (fa: Tree<A>) => Tree<B>

Added in v2.0.0 v2.0.0 中添加

model   模型

Forest (type alias)
森林(类型别名)

Signature 签名

export type Forest<A> = Array<Tree<A>>

Added in v2.0.0 v2.0.0 中添加

Tree (interface)   树(界面)

Signature 签名

export interface Tree<A> {
  readonly value: A
  readonly forest: Forest<A>
}

Added in v2.0.0 v2.0.0 中添加

sequencing   测序

flatMap   平面地图

Signature 签名

export declare const flatMap: {
  <A, B>(f: (a: A) => Tree<B>): (ma: Tree<A>) => Tree<B>
  <A, B>(ma: Tree<A>, f: (a: A) => Tree<B>): Tree<B>
}

Added in v2.14.0 v2.14.0 中添加

flatten   压扁

Signature 签名

export declare const flatten: <A>(mma: Tree<Tree<A>>) => Tree<A>

Added in v2.0.0 v2.0.0 中添加

traversing   穿越

sequence   顺序

Signature 签名

export declare const sequence: Sequence1<'Tree'>

Added in v2.6.3 v2.6.3 中添加

traverse   遍历

Signature 签名

export declare const traverse: PipeableTraverse1<'Tree'>

Added in v2.6.3 v2.6.3 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'Tree'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

ap   美联社

Signature 签名

export declare const ap: <A>(fa: Tree<A>) => <B>(fab: Tree<(a: A) => B>) => Tree<B>

Added in v2.0.0 v2.0.0 中添加

apFirst   应用程序第一

Combine two effectful actions, keeping only the result of the first.
结合两个有效的操作,仅保留第一个操作的结果。

Signature 签名

export declare const apFirst: <B>(second: Tree<B>) => <A>(first: Tree<A>) => Tree<A>

Added in v2.0.0 v2.0.0 中添加

apSecond   ap秒

Combine two effectful actions, keeping only the result of the second.
结合两个有效的操作,只保留第二个的结果。

Signature 签名

export declare const apSecond: <B>(second: Tree<B>) => <A>(first: Tree<A>) => Tree<B>

Added in v2.0.0 v2.0.0 中添加

chainFirst   链优先

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
按顺序组成计算,使用一个计算的返回值来确定下一个计算并仅保留第一个计算的结果。

Signature 签名

export declare const chainFirst: <A, B>(f: (a: A) => Tree<B>) => (first: Tree<A>) => Tree<A>

Added in v2.0.0 v2.0.0 中添加

drawForest   绘制森林

Neat 2-dimensional drawing of a forest
整齐的二维森林图

Signature 签名

export declare function drawForest(forest: Forest<string>): string

Added in v2.0.0 v2.0.0 中添加

drawTree   画树

Neat 2-dimensional drawing of a tree
整齐的二维树图

Signature 签名

export declare function drawTree(tree: Tree<string>): string

Example 例子

import { make, drawTree } from 'fp-ts/Tree'

const fa = make('a', [make('b'), make('c'), make('d', [make('e'), make('f')])])

assert.strictEqual(
  drawTree(fa),
  `a
├─ b
├─ c
└─ d
   ├─ e
   └─ f`
)

Added in v2.0.0 v2.0.0 中添加

duplicate   复制

Signature 签名

export declare const duplicate: <A>(wa: Tree<A>) => Tree<Tree<A>>

Added in v2.0.0 v2.0.0 中添加

elem   埃莱姆

Signature 签名

export declare function elem<A>(E: Eq<A>): (a: A, fa: Tree<A>) => boolean

Added in v2.0.0 v2.0.0 中添加

exists   存在

Signature 签名

export declare const exists: <A>(predicate: Predicate<A>) => (ma: Tree<A>) => boolean

Added in v2.11.0 v2.11.0 中添加

extend   延长

Signature 签名

export declare const extend: <A, B>(f: (wa: Tree<A>) => B) => (wa: Tree<A>) => Tree<B>

Added in v2.0.0 v2.0.0 中添加

zone of death
死亡地带

tree 

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass T.Functor instead of T.tree (where T is from import T from 'fp-ts/Tree')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 T.Functor 而不是 T.tree (其中 T 来自 import T from 'fp-ts/Tree'

Signature 签名

export declare const tree: Monad1<'Tree'> & Foldable1<'Tree'> & Traversable1<'Tree'> & Comonad1<'Tree'>

Added in v2.0.0 v2.0.0 中添加

Tuple overview  元组概述

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


Extract   提炼

extract   提炼

Signature 签名

export declare const extract: <E, A>(wa: [A, E]) => A

Added in v2.6.2 v2.6.2 中添加

folding   折叠式的

foldMap   折叠图

Signature 签名

export declare const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <E>(fa: [A, E]) => M

Added in v2.0.0 v2.0.0 中添加

reduce   减少

Signature 签名

export declare const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <E>(fa: [A, E]) => B

Added in v2.0.0 v2.0.0 中添加

reduceRight   减少右

Signature 签名

export declare const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <E>(fa: [A, E]) => B

Added in v2.0.0 v2.0.0 中添加

instances   实例

Bifunctor   双函子

Signature 签名

export declare const Bifunctor: Bifunctor2<'Tuple'>

Added in v2.7.0 v2.7.0 中添加

Comonad   科莫纳德

Signature 签名

export declare const Comonad: Comonad2<'Tuple'>

Added in v2.7.0 v2.7.0 中添加

Foldable   折叠式

Signature 签名

export declare const Foldable: Foldable2<'Tuple'>

Added in v2.7.0 v2.7.0 中添加

Functor   函子

Signature 签名

export declare const Functor: Functor2<'Tuple'>

Added in v2.7.0 v2.7.0 中添加

Semigroupoid   半群胚

Signature 签名

export declare const Semigroupoid: Semigroupoid2<'Tuple'>

Added in v2.7.0 v2.7.0 中添加

Traversable   可穿越

Signature 签名

export declare const Traversable: Traversable2<'Tuple'>

Added in v2.7.0 v2.7.0 中添加

getApplicative  获取应用程序

Signature 签名

export declare function getApplicative<M>(M: Monoid<M>): Applicative2C<URI, M>

Added in v2.0.0 v2.0.0 中添加

getApply   获取申请

Signature 签名

export declare function getApply<S>(S: Semigroup<S>): Apply2C<URI, S>

Added in v2.0.0 v2.0.0 中添加

getChain   获取链

Signature 签名

export declare function getChain<S>(S: Semigroup<S>): Chain2C<URI, S>

Added in v2.0.0 v2.0.0 中添加

getChainRec   获取链记录

Signature 签名

export declare function getChainRec<M>(M: Monoid<M>): ChainRec2C<URI, M>

Added in v2.0.0 v2.0.0 中添加

getMonad   获取单子

Signature 签名

export declare function getMonad<M>(M: Monoid<M>): Monad2C<URI, M>

Added in v2.0.0 v2.0.0 中添加

mapping   映射

bimap   双图

Map a pair of functions over the two type arguments of the bifunctor.
将一对函数映射到双函子的两个类型参数上。

Signature 签名

export declare const bimap: <E, G, A, B>(mapSnd: (e: E) => G, mapFst: (a: A) => B) => (fa: [A, E]) => [B, G]

Added in v2.0.0 v2.0.0 中添加

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <E, B>(fab: [(a: A) => B, E]) => [B, E]

Added in v2.10.0 v2.10.0 中添加

mapFst   映射Fst

Map a function over the first component of a Tuple.
将函数映射到 Tuple 的第一个组件。

This is the map operation of the Functor instance.
这是 Functor 实例的 map 操作。

Signature 签名

export declare const mapFst: <A, B>(f: (a: A) => B) => <E>(fa: [A, E]) => [B, E]

Added in v2.0.0 v2.0.0 中添加

mapSnd   地图Snd

Map a function over the second component of a Tuple.
将函数映射到 Tuple 的第二个组件。

This is the mapLeft operation of the Bifunctor instance.
这是 Bifunctor 实例的 mapLeft 操作。

Signature 签名

export declare const mapSnd: <E, G>(f: (e: E) => G) => <A>(fa: [A, E]) => [A, G]

Added in v2.10.0 v2.10.0 中添加

traversing   穿越

sequence   顺序

Signature 签名

export declare const sequence: Sequence2<'Tuple'>

Added in v2.6.3 v2.6.3 中添加

traverse   遍历

Signature 签名

export declare const traverse: PipeableTraverse2<'Tuple'>

Added in v2.6.3 v2.6.3 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'Tuple'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

compose   撰写

Signature 签名

export declare const compose: <A, B>(ab: [B, A]) => <C>(bc: [C, B]) => [C, A]

Added in v2.0.0 v2.0.0 中添加

duplicate   复制

Signature 签名

export declare const duplicate: <E, A>(wa: [A, E]) => [[A, E], E]

Added in v2.0.0 v2.0.0 中添加

extend   延长

Signature 签名

export declare const extend: <E, A, B>(f: (wa: [A, E]) => B) => (wa: [A, E]) => [B, E]

Added in v2.0.0 v2.0.0 中添加

fst   时间

Signature 签名

export declare const fst: <A, E>(ea: [A, E]) => A

Added in v2.0.0 v2.0.0 中添加

snd   斯德

Signature 签名

export declare const snd: <A, E>(ea: [A, E]) => E

Added in v2.0.0 v2.0.0 中添加

swap   交换

Signature 签名

export declare const swap: <A, E>(ea: [A, E]) => [E, A]

Added in v2.0.0 v2.0.0 中添加

zone of death
死亡地带

mapLeft 地图左

Use mapSnd instead. 请改用 mapSnd

Signature 签名

export declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: [A, E]) => [A, G]

Added in v2.0.0 v2.0.0 中添加

map 地图

Use mapFst instead. 请改用 mapFst

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => <E>(fa: [A, E]) => [B, E]

Added in v2.0.0 v2.0.0 中添加

tuple 元组

This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor instance, pass T.Functor instead of T.tuple (where T is from import T from 'fp-ts/Tuple')
此实例已弃用,请改用小型特定实例。例如,如果函数需要 Functor 实例,请传递 T.Functor 而不是 T.tuple (其中 T 来自 import T from 'fp-ts/Tuple'

Signature 签名

export declare const tuple: Semigroupoid2<'Tuple'> &
  Bifunctor2<'Tuple'> &
  Comonad2<'Tuple'> &
  Foldable2<'Tuple'> &
  Traversable2<'Tuple'>

Added in v2.0.0 v2.0.0 中添加

Unfoldable overview  展开概述

This class identifies data structures which can be unfolded, generalizing unfold on arrays.
此类标识可以展开的数据结构,概括数组上的 unfold

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


model   模型

Unfoldable (interface)   可展开(接口)

Signature 签名

export interface Unfoldable<F> {
  readonly URI: F
  readonly unfold: <A, B>(b: B, f: (b: B) => Option<[A, B]>) => HKT<F, A>
}

Added in v2.0.0 v2.0.0 中添加

Unfoldable1 (interface)
可折叠1(接口)

Signature 签名

export interface Unfoldable1<F extends URIS> {
  readonly URI: F
  readonly unfold: <A, B>(b: B, f: (b: B) => Option<[A, B]>) => Kind<F, A>
}

Added in v2.0.0 v2.0.0 中添加

Unfoldable2 (interface)
可折叠2(界面)

Signature 签名

export interface Unfoldable2<F extends URIS2> {
  readonly URI: F
  readonly unfold: <E, A, B>(b: B, f: (b: B) => Option<[A, B]>) => Kind2<F, E, A>
}

Added in v2.0.0 v2.0.0 中添加

Unfoldable2C (interface)
Unfoldable2C(接口)

Signature 签名

export interface Unfoldable2C<F extends URIS2, E> {
  readonly URI: F
  readonly _E: E
  readonly unfold: <A, B>(b: B, f: (b: B) => Option<[A, B]>) => Kind2<F, E, A>
}

Added in v2.0.0 v2.0.0 中添加

Unfoldable3 (interface)
可折叠3(界面)

Signature 签名

export interface Unfoldable3<F extends URIS3> {
  readonly URI: F
  readonly unfold: <R, E, A, B>(b: B, f: (b: B) => Option<[A, B]>) => Kind3<F, R, E, A>
}

Added in v2.0.0 v2.0.0 中添加

Unfoldable3C (interface)
Unfoldable3C(接口)

Signature 签名

export interface Unfoldable3C<F extends URIS3, E> {
  readonly URI: F
  readonly _E: E
  readonly unfold: <R, A, B>(b: B, f: (b: B) => Option<[A, B]>) => Kind3<F, R, E, A>
}

Added in v2.10.0 v2.10.0 中添加

Unfoldable4 (interface)
可折叠4(界面)

Signature 签名

export interface Unfoldable4<F extends URIS4> {
  readonly URI: F
  readonly unfold: <S, R, E, A, B>(b: B, f: (b: B) => Option<[A, B]>) => Kind4<F, S, R, E, A>
}

Added in v2.0.0 v2.0.0 中添加

ValidationT overview  验证概述

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


zone of death
死亡地带

ValidationM1 验证M1 (interface)   (界面)

Signature 签名

export interface ValidationM1<M extends URIS, E> extends ApplicativeComposition12C<M, E.URI, E> {
  readonly chain: <A, B>(ma: ValidationT1<M, E, A>, f: (a: A) => ValidationT1<M, E, B>) => ValidationT1<M, E, B>

  readonly alt: <A>(fa: ValidationT1<M, E, A>, that: LazyArg<ValidationT1<M, E, A>>) => ValidationT1<M, E, A>
}

Added in v2.0.0 v2.0.0 中添加

ValidationM2 验证M2 (interface)   (界面)

Signature 签名

export interface ValidationM2<M extends URIS2, E> extends ApplicativeComposition22C<M, E.URI, E> {
  readonly chain: <R, A, B>(
    ma: ValidationT2<M, R, E, A>,

    f: (a: A) => ValidationT2<M, R, E, B>
  ) => ValidationT2<M, R, E, B>

  readonly alt: <R, A>(
    fa: ValidationT2<M, R, E, A>,
    that: LazyArg<ValidationT2<M, R, E, A>>
  ) => ValidationT2<M, R, E, A>
}

Added in v2.0.0 v2.0.0 中添加

ValidationM 验证M (interface)   (界面)

Signature 签名

export interface ValidationM<M, E> extends ApplicativeCompositionHKT2C<M, E.URI, E> {
  readonly chain: <A, B>(ma: ValidationT<M, E, A>, f: (a: A) => ValidationT<M, E, B>) => ValidationT<M, E, B>

  readonly alt: <A>(fa: ValidationT<M, E, A>, that: LazyArg<ValidationT<M, E, A>>) => ValidationT<M, E, A>
}

Added in v2.0.0 v2.0.0 中添加

ValidationT1 验证T1 (type alias)   (类型别名)

Signature 签名

export type ValidationT1<M extends URIS, E, A> = Kind<M, Either<E, A>>

Added in v2.0.0 v2.0.0 中添加

ValidationT2 验证T2 (type alias)   (类型别名)

Signature 签名

export type ValidationT2<M extends URIS2, R, E, A> = Kind2<M, R, Either<E, A>>

Added in v2.0.0 v2.0.0 中添加

ValidationT 验证T (interface)   (界面)

Signature 签名

export interface ValidationT<M, E, A> extends HKT<M, Either<E, A>> {}

Added in v2.0.0 v2.0.0 中添加

getValidationM 获取验证M

Use EitherT instead. 请改用 EitherT

Signature 签名

export declare function getValidationM<E, M extends URIS2>(S: Semigroup<E>, M: Monad2<M>): ValidationM2<M, E>
export declare function getValidationM<E, M extends URIS>(S: Semigroup<E>, M: Monad1<M>): ValidationM1<M, E>
export declare function getValidationM<E, M>(S: Semigroup<E>, M: Monad<M>): ValidationM<M, E>

Added in v2.0.0 v2.0.0 中添加

void overview  无效概述

Added in v2.11.0 v2.11.0 中添加


Table of contents
目录


instances   实例

Monoid   幺半群

Signature 签名

export declare const Monoid: M.Monoid<void>

Added in v2.11.0 v2.11.0 中添加

Semigroup   半群

Signature 签名

export declare const Semigroup: Se.Semigroup<void>

Added in v2.11.0 v2.11.0 中添加

Witherable overview  枯萎概述

Witherable represents data structures which can be partitioned with effects in some Applicative functor.
Witherable 表示可以在某些 Applicative 函子中使用效果进行分区的数据结构。

Adapted from https://github.com/LiamGoodacre/purescript-filterable/blob/master/src/Data/Witherable.purs
改编自https://github.com/LiamGoodacre/purescript-filterable/blob/master/src/Data/Witherable.purs

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


defaults   默认值

wiltDefault   枯萎默认

Return a wilt implementation from Traversable and Compactable.
TraversableCompactable 返回 wilt 实现。

Signature 签名

export declare function wiltDefault<W extends URIS2, E>(
  T: Traversable2C<W, E>,
  C: Compactable2<W>
): Witherable2C<W, E>['wilt']
export declare function wiltDefault<W extends URIS2, E>(
  T: Traversable2<W>,
  C: Compactable2C<W, E>
): Witherable2C<W, E>['wilt']
export declare function wiltDefault<W extends URIS>(T: Traversable1<W>, C: Compactable1<W>): Witherable1<W>['wilt']
export declare function wiltDefault<W>(T: Traversable<W>, C: Compactable<W>): Witherable<W>['wilt']

Added in v2.11.0 v2.11.0 中添加

witherDefault   枯萎默认

Return a wither implementation from Traversable and Compactable.
TraversableCompactable 返回 wither 实现。

Signature 签名

export declare function witherDefault<W extends URIS2, E>(
  T: Traversable2C<W, E>,
  C: Compactable2<W>
): Witherable2C<W, E>['wither']
export declare function witherDefault<W extends URIS2, E>(
  T: Traversable2<W>,
  C: Compactable2C<W, E>
): Witherable2C<W, E>['wither']
export declare function witherDefault<W extends URIS>(T: Traversable1<W>, C: Compactable1<W>): Witherable1<W>['wither']
export declare function witherDefault<W>(T: Traversable<W>, C: Compactable<W>): Witherable<W>['wither']

Added in v2.11.0 v2.11.0 中添加

model   模型

Witherable (interface)   可枯萎(界面)

Signature 签名

export interface Witherable<T> extends Traversable<T>, Filterable<T> {
  /**
   * Partition a structure with effects
   */
  readonly wilt: Wilt<T>

  /**
   * Filter a structure  with effects
   */
  readonly wither: Wither<T>
}

Added in v2.0.0 v2.0.0 中添加

Witherable1 (interface)
枯萎1(界面)

Signature 签名

export interface Witherable1<T extends URIS> extends Traversable1<T>, Filterable1<T> {
  readonly wilt: Wilt1<T>
  readonly wither: Wither1<T>
}

Added in v2.0.0 v2.0.0 中添加

Witherable2 (interface)
枯萎2(界面)

Signature 签名

export interface Witherable2<T extends URIS2> extends Traversable2<T>, Filterable2<T> {
  readonly wilt: Wilt2<T>
  readonly wither: Wither2<T>
}

Added in v2.0.0 v2.0.0 中添加

Witherable2C (interface)
Witherable2C(接口)

Signature 签名

export interface Witherable2C<T extends URIS2, TL> extends Traversable2C<T, TL>, Filterable2C<T, TL> {
  readonly wilt: Wilt2C<T, TL>
  readonly wither: Wither2C<T, TL>
}

Added in v2.0.0 v2.0.0 中添加

Witherable3 (interface)
枯萎3(界面)

Signature 签名

export interface Witherable3<T extends URIS3> extends Traversable3<T>, Filterable3<T> {
  readonly wilt: Wilt3<T>
  readonly wither: Wither3<T>
}

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

FilterE1 (interface)   过滤器E1(接口)

Signature 签名

export interface FilterE1<G extends URIS> {
  <F extends URIS3>(F: Applicative3<F>): <A, R, E>(
    predicate: (a: A) => Kind3<F, R, E, boolean>
  ) => (ga: Kind<G, A>) => Kind3<F, R, E, Kind<G, A>>
  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R>(
    predicate: (a: A) => Kind3<F, R, E, boolean>
  ) => (ga: Kind<G, A>) => Kind3<F, R, E, Kind<G, A>>
  <F extends URIS2>(F: Applicative2<F>): <A, E>(
    predicate: (a: A) => Kind2<F, E, boolean>
  ) => (ga: Kind<G, A>) => Kind2<F, E, Kind<G, A>>
  <F extends URIS2, E>(F: Applicative2C<F, E>): <A>(
    predicate: (a: A) => Kind2<F, E, boolean>
  ) => (ga: Kind<G, A>) => Kind2<F, E, Kind<G, A>>
  <F extends URIS>(F: Applicative1<F>): <A>(
    predicate: (a: A) => Kind<F, boolean>
  ) => (ga: Kind<G, A>) => Kind<F, Kind<G, A>>
  <F>(F: Applicative<F>): <A>(predicate: (a: A) => HKT<F, boolean>) => (ga: Kind<G, A>) => HKT<F, Kind<G, A>>
}

Added in v2.11.0 v2.11.0 中添加

PipeableWilt (interface)
PipeableWilt(接口)

Signature 签名

export interface PipeableWilt<W> {
  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B, C>(
    f: (a: A) => Kind3<F, R, E, Either<B, C>>
  ) => (wa: HKT<W, A>) => Kind3<F, R, E, Separated<HKT<W, B>, HKT<W, C>>>
  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B, C>(
    f: (a: A) => Kind3<F, R, E, Either<B, C>>
  ) => (wa: HKT<W, A>) => Kind3<F, R, E, Separated<HKT<W, B>, HKT<W, C>>>
  <F extends URIS2>(F: Applicative2<F>): <A, E, B, C>(
    f: (a: A) => Kind2<F, E, Either<B, C>>
  ) => (wa: HKT<W, A>) => Kind2<F, E, Separated<HKT<W, B>, HKT<W, C>>>
  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B, C>(
    f: (a: A) => Kind2<F, E, Either<B, C>>
  ) => (wa: HKT<W, A>) => Kind2<F, E, Separated<HKT<W, B>, HKT<W, C>>>
  <F extends URIS>(F: Applicative1<F>): <A, B, C>(
    f: (a: A) => Kind<F, Either<B, C>>
  ) => (wa: HKT<W, A>) => Kind<F, Separated<HKT<W, B>, HKT<W, C>>>
  <F>(F: Applicative<F>): <A, B, C>(
    f: (a: A) => HKT<F, Either<B, C>>
  ) => (wa: HKT<W, A>) => HKT<F, Separated<HKT<W, B>, HKT<W, C>>>
}

Added in v2.6.5 v2.6.5 中添加

PipeableWilt1 (interface)
PipeableWilt1(接口)

Signature 签名

export interface PipeableWilt1<W extends URIS> {
  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B, C>(
    f: (a: A) => Kind3<F, R, E, Either<B, C>>
  ) => (wa: Kind<W, A>) => Kind3<F, R, E, Separated<Kind<W, B>, Kind<W, C>>>
  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B, C>(
    f: (a: A) => Kind3<F, R, E, Either<B, C>>
  ) => (wa: Kind<W, A>) => Kind3<F, R, E, Separated<Kind<W, B>, Kind<W, C>>>
  <F extends URIS2>(F: Applicative2<F>): <A, E, B, C>(
    f: (a: A) => Kind2<F, E, Either<B, C>>
  ) => (wa: Kind<W, A>) => Kind2<F, E, Separated<Kind<W, B>, Kind<W, C>>>
  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B, C>(
    f: (a: A) => Kind2<F, E, Either<B, C>>
  ) => (wa: Kind<W, A>) => Kind2<F, E, Separated<Kind<W, B>, Kind<W, C>>>
  <F extends URIS>(F: Applicative1<F>): <A, B, C>(
    f: (a: A) => Kind<F, Either<B, C>>
  ) => (wa: Kind<W, A>) => Kind<F, Separated<Kind<W, B>, Kind<W, C>>>
  <F>(F: Applicative<F>): <A, B, C>(
    f: (a: A) => HKT<F, Either<B, C>>
  ) => (wa: Kind<W, A>) => HKT<F, Separated<Kind<W, B>, Kind<W, C>>>
}

Added in v2.6.5 v2.6.5 中添加

PipeableWilt2 (interface)
PipeableWilt2(接口)

Signature 签名

export interface PipeableWilt2<W extends URIS2> {
  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B, C>(
    f: (a: A) => Kind3<F, R, FE, Either<B, C>>
  ) => <WE>(wa: Kind2<W, WE, A>) => Kind3<F, R, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>
  <F extends URIS2>(F: Applicative2<F>): <A, FE, B, C>(
    f: (a: A) => Kind2<F, FE, Either<B, C>>
  ) => <WE>(wa: Kind2<W, WE, A>) => Kind2<F, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>
  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B, C>(
    f: (a: A) => Kind2<F, FE, Either<B, C>>
  ) => <WE>(wa: Kind2<W, WE, A>) => Kind2<F, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>
  <F extends URIS>(F: Applicative1<F>): <A, B, C>(
    f: (a: A) => Kind<F, Either<B, C>>
  ) => <WE>(wa: Kind2<W, WE, A>) => Kind<F, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>
  <F>(F: Applicative<F>): <A, B, C>(
    f: (a: A) => HKT<F, Either<B, C>>
  ) => <WE>(wa: Kind2<W, WE, A>) => HKT<F, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>
}

Added in v2.6.5 v2.6.5 中添加

PipeableWilt2C (interface)
PipeableWilt2C(接口)

Signature 签名

export interface PipeableWilt2C<W extends URIS2, WE> {
  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B, C>(
    f: (a: A) => Kind3<F, R, FE, Either<B, C>>
  ) => (wa: Kind2<W, WE, A>) => Kind3<F, R, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>
  <F extends URIS2>(F: Applicative2<F>): <A, FE, B, C>(
    f: (a: A) => Kind2<F, FE, Either<B, C>>
  ) => (wa: Kind2<W, WE, A>) => Kind2<F, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>
  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B, C>(
    f: (a: A) => Kind2<F, FE, Either<B, C>>
  ) => (wa: Kind2<W, WE, A>) => Kind2<F, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>
  <F extends URIS>(F: Applicative1<F>): <A, B, C>(
    f: (a: A) => Kind<F, Either<B, C>>
  ) => (wa: Kind2<W, WE, A>) => Kind<F, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>
  <F>(F: Applicative<F>): <A, B, C>(
    f: (a: A) => HKT<F, Either<B, C>>
  ) => (wa: Kind2<W, WE, A>) => HKT<F, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>
}

Added in v2.6.5 v2.6.5 中添加

PipeableWilt3 (interface)
PipeableWilt3(接口)

Signature 签名

export interface PipeableWilt3<W extends URIS3> {
  <F extends URIS3>(F: Applicative3<F>): <A, FR, FE, B, C>(
    f: (a: A) => Kind3<F, FR, FE, Either<B, C>>
  ) => <WR, WE>(wa: Kind3<W, WR, WE, A>) => Kind3<F, FR, FE, Separated<Kind3<W, WR, WE, B>, Kind3<W, WR, WE, C>>>
  <F extends URIS2>(F: Applicative2<F>): <A, FE, B, C>(
    f: (a: A) => Kind2<F, FE, Either<B, C>>
  ) => <WR, WE>(wa: Kind3<W, WR, WE, A>) => Kind2<F, FE, Separated<Kind3<W, WR, WE, B>, Kind3<W, WR, WE, C>>>
  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B, C>(
    f: (a: A) => Kind2<F, FE, Either<B, C>>
  ) => <WR, WE>(wa: Kind3<W, WR, WE, A>) => Kind2<F, FE, Separated<Kind3<W, WR, WE, B>, Kind3<W, WR, WE, C>>>
  <F extends URIS>(F: Applicative1<F>): <A, B, C>(
    f: (a: A) => Kind<F, Either<B, C>>
  ) => <WR, WE>(wa: Kind3<W, WR, WE, A>) => Kind<F, Separated<Kind3<W, WR, WE, B>, Kind3<W, WR, WE, C>>>
  <F>(F: Applicative<F>): <A, B, C>(
    f: (a: A) => HKT<F, Either<B, C>>
  ) => <WR, WE>(wa: Kind3<W, WR, WE, A>) => HKT<F, Separated<Kind3<W, WR, WE, B>, Kind3<W, WR, WE, C>>>
}

Added in v2.6.5 v2.6.5 中添加

PipeableWither (interface)
PipeableWither(接口)

Signature 签名

export interface PipeableWither<W> {
  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(
    f: (a: A) => Kind3<F, R, E, Option<B>>
  ) => (ta: HKT<W, A>) => Kind3<F, R, E, HKT<W, B>>
  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(
    f: (a: A) => Kind3<F, R, E, Option<B>>
  ) => (ta: HKT<W, A>) => Kind3<F, R, E, HKT<W, B>>
  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(
    f: (a: A) => Kind2<F, E, Option<B>>
  ) => (ta: HKT<W, A>) => Kind2<F, E, HKT<W, B>>
  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(
    f: (a: A) => Kind2<F, E, Option<B>>
  ) => (ta: HKT<W, A>) => Kind2<F, E, HKT<W, B>>
  <F extends URIS>(F: Applicative1<F>): <A, B>(f: (a: A) => Kind<F, Option<B>>) => (ta: HKT<W, A>) => Kind<F, HKT<W, B>>
  <F>(F: Applicative<F>): <A, B>(f: (a: A) => HKT<F, Option<B>>) => (ta: HKT<W, A>) => HKT<F, HKT<W, B>>
}

Added in v2.6.5 v2.6.5 中添加

PipeableWither1 (interface)
PipeableWither1(接口)

Signature 签名

export interface PipeableWither1<W extends URIS> {
  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(
    f: (a: A) => Kind3<F, R, E, Option<B>>
  ) => (ta: Kind<W, A>) => Kind3<F, R, E, Kind<W, B>>
  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(
    f: (a: A) => Kind3<F, R, E, Option<B>>
  ) => (ta: Kind<W, A>) => Kind3<F, R, E, Kind<W, B>>
  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(
    f: (a: A) => Kind2<F, E, Option<B>>
  ) => (ta: Kind<W, A>) => Kind2<F, E, Kind<W, B>>
  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(
    f: (a: A) => Kind2<F, E, Option<B>>
  ) => (ta: Kind<W, A>) => Kind2<F, E, Kind<W, B>>
  <F extends URIS>(F: Applicative1<F>): <A, B>(
    f: (a: A) => Kind<F, Option<B>>
  ) => (ta: Kind<W, A>) => Kind<F, Kind<W, B>>
  <F>(F: Applicative<F>): <A, B>(f: (a: A) => HKT<F, Option<B>>) => (ta: Kind<W, A>) => HKT<F, Kind<W, B>>
}

Added in v2.6.5 v2.6.5 中添加

PipeableWither2 (interface)
PipeableWither2(接口)

Signature 签名

export interface PipeableWither2<W extends URIS2> {
  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B>(
    f: (a: A) => Kind3<F, R, FE, Option<B>>
  ) => <WE>(ta: Kind2<W, WE, A>) => Kind3<F, R, FE, Kind2<W, WE, B>>
  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(
    f: (a: A) => Kind2<F, FE, Option<B>>
  ) => <WE>(ta: Kind2<W, WE, A>) => Kind2<F, FE, Kind2<W, WE, B>>
  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(
    f: (a: A) => Kind2<F, FE, Option<B>>
  ) => <WE>(ta: Kind2<W, WE, A>) => Kind2<F, FE, Kind2<W, WE, B>>
  <F extends URIS>(F: Applicative1<F>): <A, B>(
    f: (a: A) => Kind<F, Option<B>>
  ) => <WE>(ta: Kind2<W, WE, A>) => Kind<F, Kind2<W, WE, B>>
  <F>(F: Applicative<F>): <A, B>(f: (a: A) => HKT<F, Option<B>>) => <WE>(ta: Kind2<W, WE, A>) => HKT<F, Kind2<W, WE, B>>
}

Added in v2.6.5 v2.6.5 中添加

PipeableWither2C (interface)
PipeableWither2C(接口)

Signature 签名

export interface PipeableWither2C<W extends URIS2, WE> {
  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B>(
    f: (a: A) => Kind3<F, R, FE, Option<B>>
  ) => (ta: Kind2<W, WE, A>) => Kind3<F, R, FE, Kind2<W, WE, B>>
  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(
    f: (a: A) => Kind2<F, FE, Option<B>>
  ) => (ta: Kind2<W, WE, A>) => Kind2<F, FE, Kind2<W, WE, B>>
  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(
    f: (a: A) => Kind2<F, FE, Option<B>>
  ) => (ta: Kind2<W, WE, A>) => Kind2<F, FE, Kind2<W, WE, B>>
  <F extends URIS>(F: Applicative1<F>): <A, B>(
    f: (a: A) => Kind<F, Option<B>>
  ) => (ta: Kind2<W, WE, A>) => Kind<F, Kind2<W, WE, B>>
  <F>(F: Applicative<F>): <A, B>(f: (a: A) => HKT<F, Option<B>>) => (ta: Kind2<W, WE, A>) => HKT<F, Kind2<W, WE, B>>
}

Added in v2.6.5 v2.6.5 中添加

PipeableWither3 (interface)
PipeableWither3(接口)

Signature 签名

export interface PipeableWither3<W extends URIS3> {
  <F extends URIS3>(F: Applicative3<F>): <A, FR, FE, B>(
    f: (a: A) => Kind3<F, FR, FE, Option<B>>
  ) => <WR, WE>(ta: Kind3<W, WR, WE, A>) => Kind3<F, FR, FE, Kind3<W, WR, WE, B>>
  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(
    f: (a: A) => Kind2<F, FE, Option<B>>
  ) => <WR, WE>(ta: Kind3<W, WR, WE, A>) => Kind2<F, FE, Kind3<W, WR, WE, B>>
  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(
    f: (a: A) => Kind2<F, FE, Option<B>>
  ) => <WR, WE>(ta: Kind3<W, WR, WE, A>) => Kind2<F, FE, Kind3<W, WR, WE, B>>
  <F extends URIS>(F: Applicative1<F>): <A, B>(
    f: (a: A) => Kind<F, Option<B>>
  ) => <WR, WE>(ta: Kind3<W, WR, WE, A>) => Kind<F, Kind3<W, WR, WE, B>>
  <F>(F: Applicative<F>): <A, B>(
    f: (a: A) => HKT<F, Option<B>>
  ) => <WR, WE>(ta: Kind3<W, WR, WE, A>) => HKT<F, Kind3<W, WR, WE, B>>
}

Added in v2.6.5 v2.6.5 中添加

Wilt (interface)   威尔特(界面)

Signature 签名

export interface Wilt<W> {
  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B, C>(
    wa: HKT<W, A>,
    f: (a: A) => Kind3<F, R, E, Either<B, C>>
  ) => Kind3<F, R, E, Separated<HKT<W, B>, HKT<W, C>>>
  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B, C>(
    wa: HKT<W, A>,
    f: (a: A) => Kind3<F, R, E, Either<B, C>>
  ) => Kind3<F, R, E, Separated<HKT<W, B>, HKT<W, C>>>
  <F extends URIS2>(F: Applicative2<F>): <A, E, B, C>(
    wa: HKT<W, A>,
    f: (a: A) => Kind2<F, E, Either<B, C>>
  ) => Kind2<F, E, Separated<HKT<W, B>, HKT<W, C>>>
  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B, C>(
    wa: HKT<W, A>,
    f: (a: A) => Kind2<F, E, Either<B, C>>
  ) => Kind2<F, E, Separated<HKT<W, B>, HKT<W, C>>>
  <F extends URIS>(F: Applicative1<F>): <A, B, C>(
    wa: HKT<W, A>,
    f: (a: A) => Kind<F, Either<B, C>>
  ) => Kind<F, Separated<HKT<W, B>, HKT<W, C>>>
  <F>(F: Applicative<F>): <A, B, C>(
    wa: HKT<W, A>,
    f: (a: A) => HKT<F, Either<B, C>>
  ) => HKT<F, Separated<HKT<W, B>, HKT<W, C>>>
}

Added in v2.0.0 v2.0.0 中添加

Wilt1 (interface)   Wilt1(界面)

Signature 签名

export interface Wilt1<W extends URIS> {
  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B, C>(
    wa: Kind<W, A>,
    f: (a: A) => Kind3<F, R, E, Either<B, C>>
  ) => Kind3<F, R, E, Separated<Kind<W, B>, Kind<W, C>>>
  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B, C>(
    wa: Kind<W, A>,
    f: (a: A) => Kind3<F, R, E, Either<B, C>>
  ) => Kind3<F, R, E, Separated<Kind<W, B>, Kind<W, C>>>
  <F extends URIS2>(F: Applicative2<F>): <A, E, B, C>(
    wa: Kind<W, A>,
    f: (a: A) => Kind2<F, E, Either<B, C>>
  ) => Kind2<F, E, Separated<Kind<W, B>, Kind<W, C>>>
  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B, C>(
    wa: Kind<W, A>,
    f: (a: A) => Kind2<F, E, Either<B, C>>
  ) => Kind2<F, E, Separated<Kind<W, B>, Kind<W, C>>>
  <F extends URIS>(F: Applicative1<F>): <A, B, C>(
    wa: Kind<W, A>,
    f: (a: A) => Kind<F, Either<B, C>>
  ) => Kind<F, Separated<Kind<W, B>, Kind<W, C>>>
  <F>(F: Applicative<F>): <A, B, C>(
    wa: Kind<W, A>,
    f: (a: A) => HKT<F, Either<B, C>>
  ) => HKT<F, Separated<Kind<W, B>, Kind<W, C>>>
}

Added in v2.0.0 v2.0.0 中添加

Wilt2 (interface)   Wilt2(界面)

Signature 签名

export interface Wilt2<W extends URIS2> {
  <F extends URIS3>(F: Applicative3<F>): <WE, A, R, FE, B, C>(
    wa: Kind2<W, WE, A>,
    f: (a: A) => Kind3<F, R, FE, Either<B, C>>
  ) => Kind3<F, R, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>
  <F extends URIS2>(F: Applicative2<F>): <WE, A, FE, B, C>(
    wa: Kind2<W, WE, A>,
    f: (a: A) => Kind2<F, FE, Either<B, C>>
  ) => Kind2<F, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>
  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <WE, A, B, C>(
    wa: Kind2<W, WE, A>,
    f: (a: A) => Kind2<F, FE, Either<B, C>>
  ) => Kind2<F, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>
  <F extends URIS>(F: Applicative1<F>): <E, A, B, C>(
    wa: Kind2<W, E, A>,
    f: (a: A) => Kind<F, Either<B, C>>
  ) => Kind<F, Separated<Kind2<W, E, B>, Kind2<W, E, C>>>
  <F>(F: Applicative<F>): <E, A, B, C>(
    wa: Kind2<W, E, A>,
    f: (a: A) => HKT<F, Either<B, C>>
  ) => HKT<F, Separated<Kind2<W, E, B>, Kind2<W, E, C>>>
}

Added in v2.0.0 v2.0.0 中添加

Wilt2C (interface)   Wilt2C(接口)

Signature 签名

export interface Wilt2C<W extends URIS2, E> {
  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B, C>(
    wa: Kind2<W, E, A>,
    f: (a: A) => Kind3<F, R, FE, Either<B, C>>
  ) => Kind3<F, R, FE, Separated<Kind2<W, E, B>, Kind2<W, E, C>>>
  <F extends URIS2>(F: Applicative2<F>): <A, FE, B, C>(
    wa: Kind2<W, E, A>,
    f: (a: A) => Kind2<F, FE, Either<B, C>>
  ) => Kind2<F, FE, Separated<Kind2<W, E, B>, Kind2<W, E, C>>>
  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B, C>(
    wa: Kind2<W, E, A>,
    f: (a: A) => Kind2<F, FE, Either<B, C>>
  ) => Kind2<F, FE, Separated<Kind2<W, E, B>, Kind2<W, E, C>>>
  <F extends URIS>(F: Applicative1<F>): <A, B, C>(
    wa: Kind2<W, E, A>,
    f: (a: A) => Kind<F, Either<B, C>>
  ) => Kind<F, Separated<Kind2<W, E, B>, Kind2<W, E, C>>>
  <F>(F: Applicative<F>): <A, B, C>(
    wa: Kind2<W, E, A>,
    f: (a: A) => HKT<F, Either<B, C>>
  ) => HKT<F, Separated<Kind2<W, E, B>, Kind2<W, E, C>>>
}

Added in v2.0.0 v2.0.0 中添加

Wilt3 (interface)   Wilt3(界面)

Signature 签名

export interface Wilt3<W extends URIS3> {
  <F extends URIS3>(F: Applicative3<F>): <WR, WE, A, FR, FE, B, C>(
    wa: Kind3<W, WR, WE, A>,
    f: (a: A) => Kind3<F, FR, FE, Either<B, C>>
  ) => Kind3<F, FR, FE, Separated<Kind3<W, WR, WE, B>, Kind3<W, WR, WE, C>>>
  <F extends URIS2>(F: Applicative2<F>): <R, WE, A, FE, B, C>(
    wa: Kind3<W, R, WE, A>,
    f: (a: A) => Kind2<F, FE, Either<B, C>>
  ) => Kind2<F, FE, Separated<Kind3<W, R, WE, B>, Kind3<W, R, WE, C>>>
  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <R, WE, A, B, C>(
    wa: Kind3<W, R, WE, A>,
    f: (a: A) => Kind2<F, FE, Either<B, C>>
  ) => Kind2<F, FE, Separated<Kind3<W, R, WE, B>, Kind3<W, R, WE, C>>>
  <F extends URIS>(F: Applicative1<F>): <R, E, A, B, C>(
    wa: Kind3<W, R, E, A>,
    f: (a: A) => Kind<F, Either<B, C>>
  ) => Kind<F, Separated<Kind3<W, R, E, B>, Kind3<W, R, E, C>>>
  <F>(F: Applicative<F>): <R, E, A, B, C>(
    wa: Kind3<W, R, E, A>,
    f: (a: A) => HKT<F, Either<B, C>>
  ) => HKT<F, Separated<Kind3<W, R, E, B>, Kind3<W, R, E, C>>>
}

Added in v2.0.0 v2.0.0 中添加

Wither (interface)   枯萎(界面)

Signature 签名

export interface Wither<W> {
  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(
    ta: HKT<W, A>,
    f: (a: A) => Kind3<F, R, E, Option<B>>
  ) => Kind3<F, R, E, HKT<W, B>>
  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(
    ta: HKT<W, A>,
    f: (a: A) => Kind3<F, R, E, Option<B>>
  ) => Kind3<F, R, E, HKT<W, B>>
  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(
    ta: HKT<W, A>,
    f: (a: A) => Kind2<F, E, Option<B>>
  ) => Kind2<F, E, HKT<W, B>>
  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(
    ta: HKT<W, A>,
    f: (a: A) => Kind2<F, E, Option<B>>
  ) => Kind2<F, E, HKT<W, B>>
  <F extends URIS>(F: Applicative1<F>): <A, B>(ta: HKT<W, A>, f: (a: A) => Kind<F, Option<B>>) => Kind<F, HKT<W, B>>
  <F>(F: Applicative<F>): <A, B>(ta: HKT<W, A>, f: (a: A) => HKT<F, Option<B>>) => HKT<F, HKT<W, B>>
}

Added in v2.0.0 v2.0.0 中添加

Wither1 (interface)   Wither1(界面)

Signature 签名

export interface Wither1<W extends URIS> {
  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(
    ta: Kind<W, A>,
    f: (a: A) => Kind3<F, R, E, Option<B>>
  ) => Kind3<F, R, E, Kind<W, B>>
  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(
    ta: Kind<W, A>,
    f: (a: A) => Kind3<F, R, E, Option<B>>
  ) => Kind3<F, R, E, Kind<W, B>>
  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(
    ta: Kind<W, A>,
    f: (a: A) => Kind2<F, E, Option<B>>
  ) => Kind2<F, E, Kind<W, B>>
  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(
    ta: Kind<W, A>,
    f: (a: A) => Kind2<F, E, Option<B>>
  ) => Kind2<F, E, Kind<W, B>>
  <F extends URIS>(F: Applicative1<F>): <A, B>(ta: Kind<W, A>, f: (a: A) => Kind<F, Option<B>>) => Kind<F, Kind<W, B>>
  <F>(F: Applicative<F>): <A, B>(ta: Kind<W, A>, f: (a: A) => HKT<F, Option<B>>) => HKT<F, Kind<W, B>>
}

Added in v2.0.0 v2.0.0 中添加

Wither2 (interface)   Wither2(界面)

Signature 签名

export interface Wither2<W extends URIS2> {
  <F extends URIS3>(F: Applicative3<F>): <WE, A, R, FE, B>(
    ta: Kind2<W, WE, A>,
    f: (a: A) => Kind3<F, R, FE, Option<B>>
  ) => Kind3<F, R, FE, Kind2<W, WE, B>>
  <F extends URIS2>(F: Applicative2<F>): <WE, A, FE, B>(
    ta: Kind2<W, WE, A>,
    f: (a: A) => Kind2<F, FE, Option<B>>
  ) => Kind2<F, FE, Kind2<W, WE, B>>
  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <WE, A, B>(
    ta: Kind2<W, WE, A>,
    f: (a: A) => Kind2<F, FE, Option<B>>
  ) => Kind2<F, FE, Kind2<W, WE, B>>
  <F extends URIS>(F: Applicative1<F>): <E, A, B>(
    ta: Kind2<W, E, A>,
    f: (a: A) => Kind<F, Option<B>>
  ) => Kind<F, Kind2<W, E, B>>
  <F>(F: Applicative<F>): <E, A, B>(ta: Kind2<W, E, A>, f: (a: A) => HKT<F, Option<B>>) => HKT<F, Kind2<W, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

Wither2C (interface)   Wither2C(界面)

Signature 签名

export interface Wither2C<W extends URIS2, E> {
  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B>(
    ta: Kind2<W, E, A>,
    f: (a: A) => Kind3<F, R, FE, Option<B>>
  ) => Kind3<F, R, FE, Kind2<W, E, B>>
  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(
    ta: Kind2<W, E, A>,
    f: (a: A) => Kind2<F, FE, Option<B>>
  ) => Kind2<F, FE, Kind2<W, E, B>>
  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(
    ta: Kind2<W, E, A>,
    f: (a: A) => Kind2<F, FE, Option<B>>
  ) => Kind2<F, FE, Kind2<W, E, B>>
  <F extends URIS>(F: Applicative1<F>): <A, B>(
    ta: Kind2<W, E, A>,
    f: (a: A) => Kind<F, Option<B>>
  ) => Kind<F, Kind2<W, E, B>>
  <F>(F: Applicative<F>): <A, B>(ta: Kind2<W, E, A>, f: (a: A) => HKT<F, Option<B>>) => HKT<F, Kind2<W, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

Wither3 (interface)   Wither3(界面)

Signature 签名

export interface Wither3<W extends URIS3> {
  <F extends URIS3>(F: Applicative3<F>): <WR, WE, A, FR, FE, B>(
    ta: Kind3<W, WR, WE, A>,
    f: (a: A) => Kind3<F, FR, FE, Option<B>>
  ) => Kind3<F, FR, FE, Kind3<W, WR, WE, B>>
  <F extends URIS2>(F: Applicative2<F>): <WR, WE, A, FE, B>(
    ta: Kind3<W, WR, WE, A>,
    f: (a: A) => Kind2<F, FE, Option<B>>
  ) => Kind2<F, FE, Kind3<W, WR, WE, B>>
  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <R, WE, A, B>(
    ta: Kind3<W, R, WE, A>,
    f: (a: A) => Kind2<F, FE, Option<B>>
  ) => Kind2<F, FE, Kind3<W, R, WE, B>>
  <F extends URIS>(F: Applicative1<F>): <R, E, A, B>(
    ta: Kind3<W, R, E, A>,
    f: (a: A) => Kind<F, Option<B>>
  ) => Kind<F, Kind3<W, R, E, B>>
  <F>(F: Applicative<F>): <R, E, A, B>(
    ta: Kind3<W, R, E, A>,
    f: (a: A) => HKT<F, Option<B>>
  ) => HKT<F, Kind3<W, R, E, B>>
}

Added in v2.0.0 v2.0.0 中添加

filterE   过滤器E

Filter values inside a F context.
过滤 F 上下文中的值。

See ReadonlyArray’s filterE for an example of usage.
有关用法示例,请参阅 ReadonlyArray 的@​​1#。

Signature 签名

export declare function filterE<G extends URIS>(W: Witherable1<G>): FilterE1<G>
export declare function filterE<G>(
  W: Witherable<G>
): <F>(F: Applicative<F>) => <A>(predicate: (a: A) => HKT<F, boolean>) => (ga: HKT<G, A>) => HKT<F, HKT<G, A>>

Added in v2.11.0 v2.11.0 中添加

Writer overview  作家概述

Added in v2.0.0 v2.0.0 中添加


Table of contents
目录


constructors  构造函数

tell   告诉

Appends a value to the accumulator
将值附加到累加器

Signature 签名

export declare const tell: <W>(w: W) => Writer<W, void>

Added in v2.0.0 v2.0.0 中添加

instances   实例

Functor   函子

Signature 签名

export declare const Functor: Functor2<'Writer'>

Added in v2.7.0 v2.7.0 中添加

getApplicative  获取应用程序

Signature 签名

export declare const getApplicative: <W>(M: Monoid<W>) => Applicative2C<'Writer', W>

Added in v2.10.0 v2.10.0 中添加

getApply   获取申请

Signature 签名

export declare const getApply: <W>(S: Semigroup<W>) => Apply2C<'Writer', W>

Added in v2.10.0 v2.10.0 中添加

getChain   获取链

Signature 签名

export declare function getChain<W>(S: Semigroup<W>): Chain2C<URI, W>

Added in v2.10.0 v2.10.0 中添加

getMonad   获取单子

Signature 签名

export declare function getMonad<W>(M: Monoid<W>): Monad2C<URI, W>

Added in v2.0.0 v2.0.0 中添加

getPointed   得到指点

Signature 签名

export declare const getPointed: <W>(M: Monoid<W>) => Pointed2C<'Writer', W>

Added in v2.10.0 v2.10.0 中添加

mapping   映射

flap   皮瓣

Signature 签名

export declare const flap: <A>(a: A) => <E, B>(fab: Writer<E, (a: A) => B>) => Writer<E, B>

Added in v2.10.0 v2.10.0 中添加

map   地图

map can be used to turn functions (a: A) => B into functions (fa: F<A>) => F<B> whose argument and return types use the type constructor F to represent some computational context.
map 可用于将函数 (a: A) => B 转换为函数 (fa: F<A>) => F<B> ,其参数和返回类型使用类型构造函数 F 来表示某些计算上下文。

Signature 签名

export declare const map: <A, B>(f: (a: A) => B) => <E>(fa: Writer<E, A>) => Writer<E, B>

Added in v2.0.0 v2.0.0 中添加

model   模型

Writer (interface)   作家(界面)

Signature 签名

export interface Writer<W, A> {
  (): [A, W]
}

Added in v2.0.0 v2.0.0 中添加

type lambdas   类型 lambda

URI   统一资源标识符

Signature 签名

export declare const URI: 'Writer'

Added in v2.0.0 v2.0.0 中添加

URI (type alias)
URI(类型别名)

Signature 签名

export type URI = typeof URI

Added in v2.0.0 v2.0.0 中添加

utils   实用程序

censor   审查

Modify the final accumulator value by applying a function
通过应用函数修改最终累加器值

Signature 签名

export declare const censor: <W>(f: (w: W) => W) => <A>(fa: Writer<W, A>) => Writer<W, A>

Added in v2.0.0 v2.0.0 中添加

evaluate   评价

Signature 签名

export declare const evaluate: <W, A>(fa: Writer<W, A>) => A

Added in v2.8.0 v2.8.0 中添加

execute   执行

Signature 签名

export declare const execute: <W, A>(fa: Writer<W, A>) => W

Added in v2.8.0 v2.8.0 中添加

listen  

Modifies the result to include the changes to the accumulator
修改结果以包括对累加器的更改

Signature 签名

export declare const listen: <W, A>(fa: Writer<W, A>) => Writer<W, [A, W]>

Added in v2.0.0 v2.0.0 中添加

listens  

Projects a value from modifications made to the accumulator during an action
根据操作期间对累加器所做的修改来投影值

Signature 签名

export declare const listens: <W, B>(f: (w: W) => B) => <A>(fa: Writer<W, A>) => Writer<W, [A, B]>

Added in v2.0.0 v2.0.0 中添加

pass   经过

Applies the returned function to the accumulator
将返回的函数应用于累加器

Signature 签名

export declare const pass: <W, A>(fa: Writer<W, [A, (w: W) => W]>) => Writer<W, A>

Added in v2.0.0 v2.0.0 中添加

zone of death
死亡地带

evalWriter 评估作家

Use evaluate instead 使用 evaluate 代替

Signature 签名

export declare const evalWriter: <W, A>(fa: Writer<W, A>) => A

Added in v2.0.0 v2.0.0 中添加

execWriter 执行写入器

Use execute instead 使用 execute 代替

Signature 签名

export declare const execWriter: <W, A>(fa: Writer<W, A>) => W

Added in v2.0.0 v2.0.0 中添加

writer 作家

Use Functor instead. 请改用 Functor

Signature 签名

export declare const writer: Functor2<'Writer'>

Added in v2.0.0 v2.0.0 中添加

WriterT overview  WriterT 概述

Added in v2.4.0 v2.4.0中添加


Table of contents
目录


model   模型

WriterT (interface)   WriterT(接口)

Signature 签名

export interface WriterT<M, W, A> {
  (): HKT<M, [A, W]>
}

Added in v2.4.0 v2.4.0中添加

WriterT1 (interface)   WriterT1(接口)

Signature 签名

export interface WriterT1<M extends URIS, W, A> {
  (): Kind<M, [A, W]>
}

Added in v2.4.0 v2.4.0中添加

WriterT2 (interface)   WriterT2(接口)

Signature 签名

export interface WriterT2<M extends URIS2, E, W, A> {
  (): Kind2<M, E, [A, W]>
}

Added in v2.4.0 v2.4.0中添加

utils   实用程序

WriterM (interface)   WriterM(接口)

Signature 签名

export interface WriterM<M> {
  readonly map: <W, A, B>(fa: WriterT<M, W, A>, f: (a: A) => B) => WriterT<M, W, B>
  readonly evalWriter: <W, A>(fa: WriterT<M, W, A>) => HKT<M, A>
  readonly execWriter: <W, A>(fa: WriterT<M, W, A>) => HKT<M, W>
  readonly tell: <W>(w: W) => WriterT<M, W, void>
  readonly listen: <W, A>(fa: WriterT<M, W, A>) => WriterT<M, W, [A, W]>
  readonly pass: <W, A>(fa: WriterT<M, W, [A, (w: W) => W]>) => WriterT<M, W, A>
  readonly listens: <W, A, B>(fa: WriterT<M, W, A>, f: (w: W) => B) => WriterT<M, W, [A, B]>
  readonly censor: <W, A>(fa: WriterT<M, W, A>, f: (w: W) => W) => WriterT<M, W, A>
  readonly getMonad: <W>(M: Monoid<W>) => {
    readonly _E: W
    readonly map: <A, B>(ma: WriterT<M, W, A>, f: (a: A) => B) => WriterT<M, W, B>
    readonly of: <A>(a: A) => WriterT<M, W, A>
    readonly ap: <A, B>(mab: WriterT<M, W, (a: A) => B>, ma: WriterT<M, W, A>) => WriterT<M, W, B>
    readonly chain: <A, B>(ma: WriterT<M, W, A>, f: (a: A) => WriterT<M, W, B>) => WriterT<M, W, B>
  }
}

Added in v2.4.0 v2.4.0中添加

WriterM1 (interface)   WriterM1(接口)

Signature 签名

export interface WriterM1<M extends URIS> {
  readonly map: <W, A, B>(fa: WriterT1<M, W, A>, f: (a: A) => B) => WriterT1<M, W, B>
  readonly evalWriter: <W, A>(fa: WriterT1<M, W, A>) => Kind<M, A>
  readonly execWriter: <W, A>(fa: WriterT1<M, W, A>) => Kind<M, W>
  readonly tell: <W>(w: W) => WriterT1<M, W, void>
  readonly listen: <W, A>(fa: WriterT1<M, W, A>) => WriterT1<M, W, [A, W]>
  readonly pass: <W, A>(fa: WriterT1<M, W, [A, (w: W) => W]>) => WriterT1<M, W, A>
  readonly listens: <W, A, B>(fa: WriterT1<M, W, A>, f: (w: W) => B) => WriterT1<M, W, [A, B]>
  readonly censor: <W, A>(fa: WriterT1<M, W, A>, f: (w: W) => W) => WriterT1<M, W, A>
  readonly getMonad: <W>(M: Monoid<W>) => {
    readonly _E: W
    readonly map: <A, B>(ma: WriterT1<M, W, A>, f: (a: A) => B) => WriterT1<M, W, B>
    readonly of: <A>(a: A) => WriterT1<M, W, A>
    readonly ap: <A, B>(mab: WriterT1<M, W, (a: A) => B>, ma: WriterT1<M, W, A>) => WriterT1<M, W, B>
    readonly chain: <A, B>(ma: WriterT1<M, W, A>, f: (a: A) => WriterT1<M, W, B>) => WriterT1<M, W, B>
  }
}

Added in v2.4.0 v2.4.0中添加

WriterM2 (interface)   WriterM2(接口)

Signature 签名

export interface WriterM2<M extends URIS2> {
  readonly map: <E, W, A, B>(fa: WriterT2<M, E, W, A>, f: (a: A) => B) => WriterT2<M, E, W, B>
  readonly evalWriter: <E, W, A>(fa: WriterT2<M, E, W, A>) => Kind2<M, E, A>
  readonly execWriter: <E, W, A>(fa: WriterT2<M, E, W, A>) => Kind2<M, E, W>
  readonly tell: <E, W>(w: W) => WriterT2<M, E, W, void>
  readonly listen: <E, W, A>(fa: WriterT2<M, E, W, A>) => WriterT2<M, E, W, [A, W]>
  readonly pass: <E, W, A>(fa: WriterT2<M, E, W, [A, (w: W) => W]>) => WriterT2<M, E, W, A>
  readonly listens: <E, W, A, B>(fa: WriterT2<M, E, W, A>, f: (w: W) => B) => WriterT2<M, E, W, [A, B]>
  readonly censor: <E, W, A>(fa: WriterT2<M, E, W, A>, f: (w: W) => W) => WriterT2<M, E, W, A>
  readonly getMonad: <W>(M: Monoid<W>) => {
    readonly _E: W
    readonly map: <E, A, B>(ma: WriterT2<M, E, W, A>, f: (a: A) => B) => WriterT2<M, E, W, B>
    readonly of: <E, A>(a: A) => WriterT2<M, E, W, A>
    readonly ap: <E, A, B>(mab: WriterT2<M, E, W, (a: A) => B>, ma: WriterT2<M, E, W, A>) => WriterT2<M, E, W, B>
    readonly chain: <E, A, B>(ma: WriterT2<M, E, W, A>, f: (a: A) => WriterT2<M, E, W, B>) => WriterT2<M, E, W, B>
  }
}

Added in v2.4.0 v2.4.0中添加

WriterM2C (interface)   WriterM2C(接口)

Signature 签名

export interface WriterM2C<M extends URIS2, E> {
  readonly map: <W, A, B>(fa: WriterT2<M, E, W, A>, f: (a: A) => B) => WriterT2<M, E, W, B>
  readonly evalWriter: <W, A>(fa: WriterT2<M, E, W, A>) => Kind2<M, E, A>
  readonly execWriter: <W, A>(fa: WriterT2<M, E, W, A>) => Kind2<M, E, W>
  readonly tell: <W>(w: W) => WriterT2<M, E, W, void>
  readonly listen: <W, A>(fa: WriterT2<M, E, W, A>) => WriterT2<M, E, W, [A, W]>
  readonly pass: <W, A>(fa: WriterT2<M, E, W, [A, (w: W) => W]>) => WriterT2<M, E, W, A>
  readonly listens: <W, A, B>(fa: WriterT2<M, E, W, A>, f: (w: W) => B) => WriterT2<M, E, W, [A, B]>
  readonly censor: <W, A>(fa: WriterT2<M, E, W, A>, f: (w: W) => W) => WriterT2<M, E, W, A>
  readonly getMonad: <W>(M: Monoid<W>) => {
    readonly _E: W
    readonly map: <A, B>(ma: WriterT2<M, E, W, A>, f: (a: A) => B) => WriterT2<M, E, W, B>
    readonly of: <A>(a: A) => WriterT2<M, E, W, A>
    readonly ap: <A, B>(mab: WriterT2<M, E, W, (a: A) => B>, ma: WriterT2<M, E, W, A>) => WriterT2<M, E, W, B>
    readonly chain: <A, B>(ma: WriterT2<M, E, W, A>, f: (a: A) => WriterT2<M, E, W, B>) => WriterT2<M, E, W, B>
  }
}

Added in v2.4.0 v2.4.0中添加

WriterM3 (interface)   WriterM3(接口)

Signature 签名

export interface WriterM3<M extends URIS3> {
  readonly map: <R, E, W, A, B>(fa: WriterT3<M, R, E, W, A>, f: (a: A) => B) => WriterT3<M, R, E, W, B>
  readonly evalWriter: <R, E, W, A>(fa: WriterT3<M, R, E, W, A>) => Kind3<M, R, E, A>
  readonly execWriter: <R, E, W, A>(fa: WriterT3<M, R, E, W, A>) => Kind3<M, R, E, W>
  readonly tell: <R, E, W>(w: W) => WriterT3<M, R, E, W, void>
  readonly listen: <R, E, W, A>(fa: WriterT3<M, R, E, W, A>) => WriterT3<M, R, E, W, [A, W]>
  readonly pass: <R, E, W, A>(fa: WriterT3<M, R, E, W, [A, (w: W) => W]>) => WriterT3<M, R, E, W, A>
  readonly listens: <R, E, W, A, B>(fa: WriterT3<M, R, E, W, A>, f: (w: W) => B) => WriterT3<M, R, E, W, [A, B]>
  readonly censor: <R, E, W, A>(fa: WriterT3<M, R, E, W, A>, f: (w: W) => W) => WriterT3<M, R, E, W, A>
  readonly getMonad: <W>(M: Monoid<W>) => {
    readonly _E: W
    readonly map: <R, E, A, B>(ma: WriterT3<M, R, E, W, A>, f: (a: A) => B) => WriterT3<M, R, E, W, B>
    readonly of: <R, E, A>(a: A) => WriterT3<M, R, E, W, A>
    readonly ap: <R, E, A, B>(
      mab: WriterT3<M, R, E, W, (a: A) => B>,
      ma: WriterT3<M, R, E, W, A>
    ) => WriterT3<M, R, E, W, B>
    readonly chain: <R, E, A, B>(
      ma: WriterT3<M, R, E, W, A>,
      f: (a: A) => WriterT3<M, R, E, W, B>
    ) => WriterT3<M, R, E, W, B>
  }
}

Added in v2.4.0 v2.4.0中添加

WriterT3 (interface)   WriterT3(接口)

Signature 签名

export interface WriterT3<M extends URIS3, R, E, W, A> {
  (): Kind3<M, R, E, [A, W]>
}

Added in v2.4.0 v2.4.0中添加

getWriterM   获取WriterM

Signature 签名

export declare function getWriterM<M extends URIS3>(M: Monad3<M>): WriterM3<M>
export declare function getWriterM<M extends URIS2>(M: Monad2<M>): WriterM2<M>
export declare function getWriterM<M extends URIS2, E>(M: Monad2C<M, E>): WriterM2C<M, E>
export declare function getWriterM<M extends URIS>(M: Monad1<M>): WriterM1<M>
export declare function getWriterM<M>(M: Monad<M>): WriterM<M>

Added in v2.4.0 v2.4.0中添加

Zero overview  零概览

Added in v2.11.0 v2.11.0 中添加


Table of contents
目录


do notation   做记号

guard   警卫

Signature 签名

export declare function guard<F extends URIS4>(
  F: Zero4<F>,
  P: Pointed4<F>
): <S, R, E>(b: boolean) => Kind4<F, S, R, E, void>
export declare function guard<F extends URIS3>(F: Zero3<F>, P: Pointed3<F>): <R, E>(b: boolean) => Kind3<F, R, E, void>
export declare function guard<F extends URIS3, E>(
  F: Zero3C<F, E>,
  P: Pointed3C<F, E>
): <R>(b: boolean) => Kind3<F, R, E, void>
export declare function guard<F extends URIS2>(F: Zero2<F>, P: Pointed2<F>): <E>(b: boolean) => Kind2<F, E, void>
export declare function guard<F extends URIS2, E>(
  F: Zero2C<F, E>,
  P: Pointed2C<F, E>
): (b: boolean) => Kind2<F, E, void>
export declare function guard<F extends URIS>(F: Zero1<F>, P: Pointed1<F>): (b: boolean) => Kind<F, void>
export declare function guard<F>(F: Zero<F>, P: Pointed<F>): (b: boolean) => HKT<F, void>

Added in v2.11.0 v2.11.0 中添加

model   模型

Zero (interface)   零(接口)

Signature 签名

export interface Zero<F> {
  readonly URI: F
  readonly zero: <A>() => HKT<F, A>
}

Added in v2.11.0 v2.11.0 中添加

Zero1 (interface)   零1(接口)

Signature 签名

export interface Zero1<F extends URIS> {
  readonly URI: F
  readonly zero: <A>() => Kind<F, A>
}

Added in v2.11.0 v2.11.0 中添加

Zero2 (interface)   Zero2(接口)

Signature 签名

export interface Zero2<F extends URIS2> {
  readonly URI: F
  readonly zero: <E, A>() => Kind2<F, E, A>
}

Added in v2.11.0 v2.11.0 中添加

Zero2C (interface)   Zero2C(接口)

Signature 签名

export interface Zero2C<F extends URIS2, E> {
  readonly URI: F
  readonly _E: E
  readonly zero: <A>() => Kind2<F, E, A>
}

Added in v2.11.0 v2.11.0 中添加

Zero3 (interface)   Zero3(接口)

Signature 签名

export interface Zero3<F extends URIS3> {
  readonly URI: F
  readonly zero: <R, E, A>() => Kind3<F, R, E, A>
}

Added in v2.11.0 v2.11.0 中添加

Zero3C (interface)   Zero3C(接口)

Signature 签名

export interface Zero3C<F extends URIS3, E> {
  readonly URI: F
  readonly _E: E
  readonly zero: <R, A>() => Kind3<F, R, E, A>
}

Added in v2.11.0 v2.11.0 中添加

Zero4 (interface)   Zero4(接口)

Signature 签名

export interface Zero4<F extends URIS4> {
  readonly URI: F
  readonly zero: <S, R, E, A>() => Kind4<F, S, R, E, A>
}

Added in v2.11.0 v2.11.0 中添加